Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
The destination path in the project datasets.
project_id : str, optional
The project to get files from. You need to have access to this project
for it to work. Defaults to the project set by FACULTY_PROJECT_ID in
your environment.
recursive : bool, optional
If True, allows copying directories
like a recursive copy in a filesystem. By default the action
is not recursive.
object_client : faculty.clients.object.ObjectClient, optional
Advanced - can be used to benefit from caching in chain interactions
with datasets.
"""
project_id = project_id or get_context().project_id
object_client = object_client or ObjectClient(get_session())
_create_parent_directories(destination_path, project_id, object_client)
object_client.copy(
project_id, source_path, destination_path, recursive=recursive
)
The path in the project datasets to remove.
project_id : str, optional
The project to get files from. You need to have access to this project
for it to work. Defaults to the project set by FACULTY_PROJECT_ID in
your environment.
recursive : bool, optional
If True, allows deleting directories
like a recursive delete in a filesystem. By default the action
is not recursive.
object_client : faculty.clients.object.ObjectClient, optional
Advanced - can be used to benefit from caching in chain interactions
with datasets.
"""
project_id = project_id or get_context().project_id
object_client = object_client or ObjectClient(get_session())
object_client.delete(project_id, project_path, recursive=recursive)
To set any of the domain, protocol, client ID or client secret, pass their
respective arguments. These always take higher precendence than values read
from configuration files or environment variables:
>>> faculty.client(
... "account",
... domain="services.faculty.myorganisation.com",
... protocol="http",
... client_id="d047dad1-175b-4810-84b1-c0ff6bbcf456",
... client_secret="Vk4a1FgSKlTplkK0GkToAdRTdsoU4XHuwCMQ",
... )
"""
session = faculty.session.get_session(
credentials_path=credentials_path,
profile_name=profile_name,
domain=domain,
protocol=protocol,
client_id=client_id,
client_secret=client_secret,
access_token_cache=access_token_cache,
)
client_class = faculty.clients.for_resource(resource)
return client_class(session)
for it to work. Defaults to the project set by FACULTY_PROJECT_ID in
your environment.
show_hidden : bool, optional
Include hidden files in the output. Defaults to False.
object_client : faculty.clients.object.ObjectClient, optional
Advanced - can be used to benefit from caching in chain interactions
with datasets.
Returns
-------
list
The list of files from the project datasets.
"""
project_id = project_id or get_context().project_id
object_client = object_client or ObjectClient(get_session())
list_response = object_client.list(project_id, prefix)
paths = [obj.path for obj in list_response.objects]
while list_response.next_page_token is not None:
list_response = object_client.list(
project_id, prefix, list_response.next_page_token
)
paths += [obj.path for obj in list_response.objects]
if show_hidden:
return paths
else:
non_hidden_paths = [
path
for path in paths
----------
project_path : str
The source path in the project datasets to copy.
local_path : str or os.PathLike
The destination path in the local filesystem.
project_id : str, optional
The project to get files from. You need to have access to this project
for it to work. Defaults to the project set by FACULTY_PROJECT_ID in
your environment.
object_client : faculty.clients.object.ObjectClient, optional
Advanced - can be used to benefit from caching in chain interactions
with datasets.
"""
project_id = project_id or get_context().project_id
object_client = object_client or ObjectClient(get_session())
if hasattr(os, "fspath"):
local_path = os.fspath(local_path)
if _isdir(project_path, project_id, object_client):
_get_directory(project_path, local_path, project_id, object_client)
else:
_get_file(project_path, local_path, project_id, object_client)
----------
local_path : str or os.PathLike
The source path in the local filesystem to copy.
project_path : str
The destination path in the project directory.
project_id : str, optional
The project to put files in. You need to have access to this project
for it to work. Defaults to the project set by FACULTY_PROJECT_ID in
your environment.
object_client : faculty.clients.object.ObjectClient, optional
Advanced - can be used to benefit from caching in chain interactions
with datasets.
"""
project_id = project_id or get_context().project_id
object_client = object_client or ObjectClient(get_session())
if hasattr(os, "fspath"):
local_path = os.fspath(local_path)
_create_parent_directories(project_path, project_id, object_client)
_put_recursive(local_path, project_path, project_id, object_client)
>>> ExperimentRun.query(filter=FilterBy.experiment_id() == 2)
ExperimentRunList([ExperimentRun(...)])
Filter experiment runs by a more complex condition:
>>> filter = (
... FilterBy.experiment_id().one_of([2, 3, 4]) &
... (FilterBy.metric("accuracy") > 0.9) &
... (FilterBy.param("alpha") < 0.3)
... )
>>> ExperimentRun.query("my project", filter)
ExperimentRunList([ExperimentRun(...)])
"""
session = get_session(**session_config)
project_id = resolve_project_id(session, project)
def _get_runs():
client = ExperimentClient(session)
response = client.query_runs(project_id, filter, sort)
for run in response.runs:
yield cls._from_client_model(run)
while response.pagination.next is not None:
response = client.query_runs(
project_id,
filter,
sort,
start=response.pagination.next.start,
limit=response.pagination.next.limit,