ProjectClient
polyaxon._client.project.ProjectClient(owner=None, project=None, client=None, is_offline=None, no_op=None, manual_exceptions_handling=False)
ProjectClient is a client to communicate with Polyaxon projects endpoints.
If no values are passed to this class, Polyaxon will try to resolve the owner and project from the environment:
- If you have a configured CLI, Polyaxon will use the configuration of the cli.
- If you have a cached project using the CLI, the client will default to that cached project unless you override the values.
- If you use this client in the context of a job or a service managed by Polyaxon, a configuration will be available to resolve the values based on that run.
If you intend to create a new project instance or to list projects,
only the owner
parameter is required.
-
Properties:
- project: str.
- owner: str.
- project_data: V1Project.
-
Args:
- owner: str, optional, the owner is the username or the organization name owning this project.
- project: str, optional, project name.
- client: PolyaxonClient, optional, an instance of a configured client, if not passed, a new instance will be created based on the available environment.
- is_offline: bool, optional,
To trigger the offline mode manually instead of depending on
POLYAXON_IS_OFFLINE
. - no_op: bool, optional,
To set the NO_OP mode manually instead of depending on
POLYAXON_NO_OP
.
-
Raises:
- PolyaxonClientException: If no owner is passed and Polyaxon cannot
resolve an owner from the environment.
refresh_data
refresh_data(self)
Fetches the project data from the api.
create
create(self, data)
Creates a new project based on the data passed.
-
Args:
- data: dict or V1Project, required.
-
Returns: V1Project, project instance from the response.
list
list(self, query=None, sort=None, limit=None, offset=None)
Lists projects under the current owner.
-
Args:
- query: str, optional, query filters, please refer to Project PQL
- sort: str, optional, fields to order by, please refer to Project PQL
- limit: int, optional, limit of projects to return.
- offset: int, optional, offset pages to paginate projects.
-
Returns: List[V1Project], list of project instances.
delete
delete(self)
Deletes project based on the current owner and project.
update
update(self, data)
Updates a project based on the data passed.
-
Args:
- data: Dict or V1Project, required.
-
Returns: V1Project, project instance from the response.
list_runs
list_runs(self, query=None, sort=None, limit=None, offset=None)
Lists runs under the current owner/project.
-
Args:
-
Returns: List[V1Run], list of run instances.
list_component_versions
list_component_versions(self, query=None, sort=None, limit=None, offset=None)
Lists component versions under the current owner/project.
-
Args:
- query: str, optional, query filters, please refer to Project Version PQL
- sort: str, optional, fields to order by, please refer to Project Version PQL
- limit: int, optional, limit of project versions to return.
- offset: int, optional, offset pages to paginate project versions.
-
Returns: List[V1ProjectVersion], list of component versions.
get_component_version
get_component_version(self, version)
Gets a component version under the current owner/project.
-
Args:
- version: str, required, the version name/tag.
-
Returns: V1ProjectVersion, component version.
create_component_version
create_component_version(self, data)
Creates a component version based on the data passed.
-
Args:
- data: Dict or V1ProjectVersion, required.
-
Returns: V1ProjectVersion, component version.
patch_component_version
patch_component_version(self, version, data)
Updates a component version based on the data passed.
-
Args:
- version: str, required, the version name/tag.
- data: Dict or V1ProjectVersion, required.
-
Returns: V1ProjectVersion, component version.
register_component_version
register_component_version(self, version, description=None, tags=None, content=None, run=None, force=False)
Creates or Updates a component version based on the data passed.
-
Args:
- version: str, optional, the version name/tag.
- description: str, optional, the version description.
- tags: str or List[str], optional.
- content: str or dict, optional, content/metadata (JSON object) of the version.
- run: str, optional, a uuid reference to the run.
- force: bool, optional, to force push, i.e. update if exists.
-
Returns: V1ProjectVersion, component verison.
copy_component_version
copy_component_version(self, version, to_project=None, name=None, description=None, tags=None, content=None, force=False)
Copies the component version to the same project or to a destination project.
If to_project
is provided,
the version will be copied to the destination project under the same owner/organization.
If name
is provided the version will be copied with the new name,
otherwise the copied version will be have a suffix -copy
.
- Args:
- version: str, required, the version name/tag.
- to_project: str, optional, the destination project to copy the version to.
- name: str, optional, the name to use for registering the copied version,
default value is the original version’s name with
-copy
prefix. - description: str, optional, the version description, default value is the original version’s description.
- tags: str or List[str], optional, the version description, default value is the original version’s description.
- content: str or dict, optional, content/metadata (JSON object) of the version, default value is the original version’s content.
- force: bool, optional, to force push, i.e. update if exists.
transfer_component_version
transfer_component_version(self, version, to_project)
Transfers the component version to a project under the same owner/organization.
- Args:
- version: str, required, the version name/tag.
- to_project: str, required, the destination project to transfer the version to.
delete_component_version
delete_component_version(self, version)
Deletes a component version under the current owner/project.
- Args:
- version: str, required, the version name/tag.
stage_component_version
stage_component_version(self, version, stage, reason=None, message=None, last_transition_time=None, last_update_time=None)
Creates a new a component version stage.
- Args:
- version: str, required, the version name/tag.
- stage: str, a valid Stages value.
- reason: str, optional, reason or service issuing the status change.
- message: str, optional, message to log with this status.
- last_transition_time: datetime, default
now
. - last_update_time: datetime, default
now
.
pull_component_version
pull_component_version(self, version, path)
Packages and downloads the component version to a local path.
- Args:
- version: str, required, the version name/tag.
- path: str, local path where to persist the metadata and artifacts.
list_model_versions
list_model_versions(self, query=None, sort=None, limit=None, offset=None)
Lists model versions under the current owner/project.
-
Args:
- query: str, optional, query filters, please refer to Project Version PQL
- sort: str, optional, fields to order by, please refer to Project Version PQL
- limit: int, optional, limit of project versions to return.
- offset: int, optional, offset pages to paginate project versions.
-
Returns: List[V1ProjectVersion], list of model versions.
get_model_version
get_model_version(self, version)
Gets a model version under the current owner/project.
-
Args:
- version: str, required, the version name/tag.
-
Returns: V1ProjectVersion, model version.
create_model_version
create_model_version(self, data)
Creates a model version based on the data passed.
-
Args:
- data: Dict or V1ProjectVersion, required.
-
Returns: V1ProjectVersion, model version.
patch_model_version
patch_model_version(self, version, data)
Updates a model version based on the data passed.
-
Args:
- version: str, required, the version name/tag.
- data: Dict or V1ProjectVersion, required.
-
Returns: V1ProjectVersion, model version.
register_model_version
register_model_version(self, version, description=None, tags=None, content=None, run=None, connection=None, artifacts=None, force=False)
Create or Update a model version based on the data passed.
-
Args:
- version: str, optional, the version name/tag.
- description: str, optional, the version description.
- tags: str or List[str], optional.
- content: str or dict, optional, content/metadata (JSON object) of the version.
- run: str, optional, a uuid reference to the run.
- connection: str, optional, a uuid reference to a connection.
- artifacts: List[str], optional, list of artifacts to highlight(requires passing a run)
- force: bool, optional, to force push, i.e. update if exists.
-
Returns: V1ProjectVersion, model version.
copy_model_version
copy_model_version(self, version, to_project=None, name=None, description=None, tags=None, content=None, force=False)
Copies the model version to the same project or to a destination project.
If to_project
is provided,
the version will be copied to the destination project under the same owner/organization.
If name
is provided the version will be copied with the new name,
otherwise the copied version will be have a suffix -copy
.
- Args:
- version: str, required, the version name/tag.
- to_project: str, optional, the destination project to copy the version to.
- name: str, optional, the name to use for registering the copied version,
default value is the original version’s name with
-copy
prefix. - description: str, optional, the version description, default value is the original version’s description.
- tags: str or List[str], optional, the version description, default value is the original version’s description.
- content: str or dict, optional, content/metadata (JSON object) of the version, default value is the original version’s content.
- force: bool, optional, to force push, i.e. update if exists.
transfer_model_version
transfer_model_version(self, version, to_project)
Transfers the model version to a project under the same owner/organization.
- Args:
- version: str, required, the version name/tag.
- to_project: str, required, the destination project to transfer the version to.
delete_model_version
delete_model_version(self, version)
Deletes a model version under the current owner/project.
- Args:
- version: str, required, the version name/tag.
stage_model_version
stage_model_version(self, version, stage, reason=None, message=None, last_transition_time=None, last_update_time=None)
Creates a new a model version stage.
- Args:
- version: str, required, the version name/tag.
- stage: str, a valid Stages value.
- reason: str, optional, reason or service issuing the status change.
- message: str, optional, message to log with this status.
- last_transition_time: datetime, default
now
. - last_update_time: datetime, default
now
.
pull_model_version
pull_model_version(self, version, path, download_artifacts=True)
Packages and downloads the model version to a local path.
- Args:
- version: str, required, the version name/tag.
- path: str, local path where to persist the metadata and artifacts.
- download_artifacts: bool, optional, to download the artifacts based on linked lineage.
list_artifact_versions
list_artifact_versions(self, query=None, sort=None, limit=None, offset=None)
Lists artifact versions under the current owner/project.
-
Args:
- query: str, optional, query filters, please refer to Project Version PQL
- sort: str, optional, fields to order by, please refer to Project Version PQL
- limit: int, optional, limit of project versions to return.
- offset: int, optional, offset pages to paginate project versions.
-
Returns: List[V1ProjectVersion], list of artifact versions.
get_artifact_version
get_artifact_version(self, version)
Gets an artifact version under the current owner/project.
-
Args:
- version: str, required, the version name/tag.
-
Returns: V1ProjectVersion, artifact version.
create_artifact_version
create_artifact_version(self, data)
Creates an artifact version based on the data passed.
-
Args:
- data: Dict or V1ProjectVersion, required.
-
Returns: V1ProjectVersion, artifact version.
patch_artifact_version
patch_artifact_version(self, version, data)
Updates an artifact version based on the data passed.
-
Args:
- version: str, required, the version name/tag.
- data: Dict or V1ProjectVersion, required.
-
Returns: V1ProjectVersion, artifact version.
register_artifact_version
register_artifact_version(self, version, description=None, tags=None, content=None, run=None, connection=None, artifacts=None, force=False)
Create or Update an artifact version based on the data passed.
-
Args:
- version: str, optional, the version name/tag.
- description: str, optional, the version description.
- tags: str or List[str], optional.
- content: str or dict, optional, content/metadata (JSON object) of the version.
- run: str, optional, a uuid reference to the run.
- connection: str, optional, a uuid reference to a connection.
- artifacts: List[str], optional, list of artifacts to highlight(requires passing a run)
- force: bool, optional, to force push, i.e. update if exists.
-
Returns: V1ProjectVersion, artifact version.
copy_artifact_version
copy_artifact_version(self, version, to_project=None, name=None, description=None, tags=None, content=None, force=False)
Copies the artifact version to the same project or to a destination project.
If to_project
is provided,
the version will be copied to the destination project under the same owner/organization.
If name
is provided the version will be copied with the new name,
otherwise the copied version will be have a suffix -copy
.
- Args:
- version: str, required, the version name/tag.
- to_project: str, optional, the destination project to copy the version to.
- name: str, optional, the name to use for registering the copied version,
default value is the original version’s name with
-copy
prefix. - description: str, optional, the version description, default value is the original version’s description.
- tags: str or List[str], optional, the version description, default value is the original version’s description.
- content: str or dict, optional, content/metadata (JSON object) of the version, default value is the original version’s content.
- force: bool, optional, to force push, i.e. update if exists.
transfer_artifact_version
transfer_artifact_version(self, version, to_project)
Transfers the artifact version to a project under the same owner/organization.
- Args:
- version: str, required, the version name/tag.
- to_project: str, required, the destination project to transfer the version to.
delete_artifact_version
delete_artifact_version(self, version)
Deletes an artifact version under the current owner/project.
- Args:
- version: str, required, the version name/tag.
stage_artifact_version
stage_artifact_version(self, version, stage, reason=None, message=None, last_transition_time=None, last_update_time=None)
Creates a new an artifact version stage.
- Args:
- version: str, required, the version name/tag.
- stage: str, a valid Stages value.
- reason: str, optional, reason or service issuing the status change.
- message: str, optional, message to log with this status.
- last_transition_time: datetime, default
now
. - last_update_time: datetime, default
now
.
pull_artifact_version
pull_artifact_version(self, version, path, download_artifacts=True)
Packages and downloads the artifact version to a local path.
- Args:
- version: str, required, the version name/tag.
- path: str, local path where to persist the metadata and artifacts.
- download_artifacts: bool, optional, to download the artifacts based on linked lineage.
persist_version
persist_version(self, path)
Persists a version to a local path.
- Args:
- config: V1ProjectVersion, the version config to persist.
- path: str, the path where to persist the version config.
download_artifacts_for_version
download_artifacts_for_version(self, path)
Collects and downloads all artifacts and assets linked to a version.
- Args:
- config: V1ProjectVersion, the version config to download the artifacts for.
- path: str, the path where to persist the artifacts and assets.