Apheris CLI Python API Referenceπ
apherisπ
Convenience namespace containing some common Apheris functions.
login(username=None, password=None, login_mode='sso')
π
Authenticate a user, either through their Apheris account or using their company account. Programmatic login can be achieved by supplying the apheris username/passwords directly. Alternatively the user can jump right through to using their company login by setting the login mode to "sso"
logout()
π
Logs the user out.
list_datasets(n=None, to_table=True)
π
List the n
most recently updated remote datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
Optional[int]
|
number of remote datasets to list. If None, list all. Default: None |
None
|
to_table |
bool
|
If True, a prettytable.PrettyTable is returned. If False, a list of Dictionaries will be returned. |
True
|
Returns:
Type | Description |
---|---|
Union[PrettyTable, List[dict]]
|
|
Union[PrettyTable, List[dict]]
|
|
list_models(to_table=True)
π
Convenience function to query the model list and parse the response in one call.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_table |
bool
|
If True, a prettytable.PrettyTable is returned. If False, a list of Dictionaries will be returned. |
True
|
Returns:
Type | Description |
---|---|
Union[PrettyTable, List[Dict[str, str]]]
|
|
Union[PrettyTable, List[Dict[str, str]]]
|
|
list_compute_specs(limit=10, to_table=True, verbose=False)
π
Convenience function to list the limit
most recent compute specs and optionally
output as a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit |
Optional[int]
|
The number of most recent compute specs to list. If None, all compute specs are listed. Defaults to 10. |
10
|
to_table |
bool
|
Whether to output the results as a pretty table. Defaults to True. |
True
|
verbose |
bool
|
Whether to include all details in the table. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Union[PrettyTable, List[Dict[str, str]]]
|
|
Union[PrettyTable, List[Dict[str, str]]]
|
|
list_jobs(compute_spec_id=None)
π
List all jobs of a certain compute spec
Parameters:
Name | Type | Description | Default |
---|---|---|---|
compute_spec_id |
Optional[UUID]
|
The ID of the compute spec. If |
None
|
Returns: list: List of all jobs on the specified compute spec
aphcli.api.computeπ
Functions related to the handling of Compute Specs (creation, activation, list, etc.).
set_ignore_limits(ignore)
π
Limits have been set on
create_from_args(dataset_ids=None, client_n_cpu=None, client_n_gpu=None, client_memory=None, server_n_cpu=None, server_n_gpu=None, server_memory=None, model=None, model_id=None, model_version=None)
π
Create a compute specification from raw arguments.
To describe the model, the user can supply either a dictionary with id
and version
fields, or provide them as individual arguments.
get(compute_spec_id=None)
π
Get a compute spec ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
compute_spec_id |
Optional[UUID]
|
Compute spec ID that shall be fetched. If |
None
|
Returns:
Name | Type | Description |
---|---|---|
ComputeSpec |
ComputeSpec
|
definition of a compute spec |
activate(compute_spec_id=None, verbose=False)
π
Activate a compute spec ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
compute_spec_id |
Optional[UUID]
|
Compute spec ID that shall be activated. If |
None
|
verbose |
bool
|
If |
False
|
deactivate(compute_spec_id=None, verbose=False)
π
Deactivate a compute spec ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
compute_spec_id |
Optional[UUID]
|
Compute spec ID that shall be de-activated. If |
None
|
verbose |
bool
|
If |
False
|
get_activation_status(compute_spec_id=None)
π
Get the activation status of a compute spec.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
compute_spec_id |
Optional[UUID]
|
ID of the compute spec that shall be queried. If |
None
|
get_status(compute_spec_id=None)
π
Get the detailed status of a compute spec.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
compute_spec_id |
Optional[UUID]
|
ID of the compute spec that shall be queried. If |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Dict[str, str]
|
A dict with keys |
wait_until_running(compute_spec_id, check_interval=10, timeout=600)
π
Wait until a Compute Spec's activation status is running
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
compute_spec_id |
Optional[UUID]
|
ID of the compute spec that we want to observe. If |
required |
check_interval |
float
|
Interval to check the status in seconds |
10
|
timeout |
Optional[float]
|
Timeout in seconds. If the target status is not reached within this time
a TimeoutError is raised. If set to |
600
|
aphcli.api.jobπ
Functions related to the handling of jobs (run, abort, list, status, etc.).
list_jobs(compute_spec_id=None)
π
List all jobs of a certain compute spec
Parameters:
Name | Type | Description | Default |
---|---|---|---|
compute_spec_id |
Optional[UUID]
|
The ID of the compute spec. If |
None
|
Returns: list: List of all jobs on the specified compute spec
get(job_id=None, compute_spec_id=None, verbose=True)
π
Get details on a job
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id |
Optional[UUID]
|
The ID of the job whose details shall be fetched |
None
|
compute_spec_id |
Optional[UUID]
|
deprecated, stays to prevent breaking changes |
None
|
verbose |
If |
True
|
Returns: dict: A dictionary with information on the job
status(job_id=None, compute_spec_id=None, verbose=True)
π
Get the status of a job
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id |
Optional[UUID]
|
The ID of the job whose status shall be fetched |
None
|
compute_spec_id |
Optional[UUID]
|
This argument is deprecated and |
None
|
verbose |
If |
True
|
Returns: str: A string with details on the job's status
submit(job_args, compute_spec_id=None, verbose=False)
π
Submit a job
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_args |
dict
|
Arguments for the job that you want to submit. |
required |
compute_spec_id |
Optional[UUID]
|
The ID of the compute spec. If |
None
|
verbose |
bool
|
If |
False
|
Returns: UUID: This UUID is your reference to the submitted job
abort(job_id=None, compute_spec_id=None)
π
Abort a job
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id |
Optional[UUID]
|
The ID of the job that shall be aborted |
None
|
compute_spec_id |
Optional[UUID]
|
The ID of the compute spec. If |
None
|
download_results(download_path, job_id=None, compute_spec_id=None)
π
Download the results of a job
Parameters:
Name | Type | Description | Default |
---|---|---|---|
download_path |
Union[str, Path]
|
File path to download the results to |
required |
job_id |
Optional[UUID]
|
The ID of the job |
None
|
compute_spec_id |
Optional[UUID]
|
The ID of the compute spec. If |
None
|
logs(job_id=None, compute_spec_id=None)
π
Get the logs of a job
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id |
Optional[UUID]
|
The ID of the job whose logs shall be fetched |
None
|
compute_spec_id |
Optional[UUID]
|
The ID of the compute spec. If |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string that contains the logs |
wait_until_job_finished(job_id=None, compute_spec_id=None, check_interval=3, timeout=100, warn_time=None)
π
Wait until a job is finished
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id |
Optional[UUID]
|
The ID of the job |
None
|
compute_spec_id |
Optional[UUID]
|
The ID of the compute spec. If |
None
|
check_interval |
float
|
Interval between http-requests that query the status in seconds. |
3
|
timeout |
Optional[float]
|
Maximum time to wait in seconds before a TimeoutError is raised. |
100
|
warn_time |
Optional[float]
|
After this time in seconds, a warning is fired. |
None
|
aphcli.api.modelsπ
Functions related to the Apheris Model Registry.
get_models()
π
Returns a dictionary with detailed information on models available in the model registry.
models_from_response(response)
π
Parses the raw data from the models response and extracts the list of models and available versions.
list_models(to_table=True)
π
Convenience function to query the model list and parse the response in one call.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
to_table |
bool
|
If True, a prettytable.PrettyTable is returned. If False, a list of Dictionaries will be returned. |
True
|
Returns:
Type | Description |
---|---|
Union[PrettyTable, List[Dict[str, str]]]
|
|
Union[PrettyTable, List[Dict[str, str]]]
|
|
indexed_model_list(models)
π
Convert the list of models to a tabular format for interaction
add_model_version(model_id, version, digest, commit_hash, engine_version=None)
π
Adds a new version to an existing model in the Model Registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_id |
str
|
The ID of the model to add a version to. |
required |
version |
str
|
The version tag for the new model version. |
required |
digest |
str
|
The digest of the model. |
required |
commit_hash |
str
|
The commit hash associated with this model version. |
required |
engine_version |
Optional[str]
|
Optional EngineVersion string. |
None
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
A dictionary containing the response from the API. |
Raises:
Type | Description |
---|---|
ComputeSpecException
|
If there's an error in adding the model version. |