rhino_health.lib.endpoints.code_object.code_object_dataclass
#
Module Contents#
Classes#
A mode the CodeObject will run in |
|
Location the code is stored and uploaded to the system |
|
The format the requirements are in |
|
Supported CodeObject Types |
|
The build status of the CodeObject |
|
Input arguments for creating CodeObject |
|
A CodeObject which exists on the platform |
|
Input parameters for running generalized code with multiple input and/or output datasets per container |
|
An asynchronous code run response |
|
A synchronous code run response |
|
Input for training an NVFlare Model |
|
Response of training an NVFlare Model |
Attributes#
..warning This dataclass is deprecated, will be removed soon, please use CodeLocation |
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeExecutionMode#
Bases:
str
,enum.Enum
A mode the CodeObject will run in
- DEFAULT = 'default'#
- AUTO_CONTAINER_NVFLARE = 'nvflare'#
- AUTO_CONTAINER_SNIPPET = 'snippet'#
- AUTO_CONTAINER_FILE = 'file'#
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeLocation#
Bases:
str
,enum.Enum
Location the code is stored and uploaded to the system
- DEFAULT = 'single_non_binary_file'#
- S3_MULTIPART_ZIP = 's3_multipart_zip'#
- rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeFormat#
..warning This dataclass is deprecated, will be removed soon, please use CodeLocation
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.RequirementMode#
Bases:
str
,enum.Enum
The format the requirements are in
- PYTHON_PIP = 'python_pip'#
- ANACONDA_ENVIRONMENT = 'anaconda_environment'#
- ANACONDA_SPECFILE = 'anaconda_specfile'#
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeTypes#
Bases:
str
,enum.Enum
Supported CodeObject Types
- GENERALIZED_COMPUTE = 'Generalized Compute'#
- NVIDIA_FLARE_V2_0 = 'NVIDIA FLARE v2.0'#
- NVIDIA_FLARE_V2_2 = 'NVIDIA FLARE v2.2'#
- NVIDIA_FLARE_V2_3 = 'NVIDIA FLARE v2.3'#
- NVIDIA_FLARE_V2_4 = 'NVIDIA FLARE v2.4'#
- PYTHON_CODE = 'Python Code'#
- INTERACTIVE_CONTAINER = 'Interactive Container'#
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectBuildStatus#
Bases:
str
,enum.Enum
The build status of the CodeObject
- NOT_STARTED = 'Not Started'#
- IN_PROGRESS = 'In Progress'#
- COMPLETE = 'Complete'#
- ERROR = 'Error'#
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectCreateInput(**data)#
Bases:
rhino_health.lib.dataclass.RhinoBaseModel
Input arguments for creating CodeObject
- name: str#
The name of the CodeObject
- description: str#
The description of the CodeObject
- input_data_schema_uids: List[str] = []#
A list of uids of data schemas this CodeObject expects input datasets to adhere to.
- output_data_schema_uids: List[str | None] = []#
A list of uids of data schemas this CodeObject expects output datasets to adhere to.
- project_uid: typing_extensions.Annotated[str, Field(alias='project')]#
The CodeObject project
- code_type: typing_extensions.Annotated[str, Field(alias='type')]#
The code type which corresponds to the CodeTypes enum
- base_version_uid: str | None = ''#
The first version of the CodeObject if multiple versions exist. You can also use add_version_if_exists=True when creating the code object in create_code_object if an existing code object with the same name exists
- config: dict | None#
Additional configuration of the CodeObject. The contents will differ based on the model_type and code_run_type.
See also
Examples
- CodeTypes.GENERALIZED_COMPUTE and CodeTypes.INTERACTIVE_CONTAINER
container_image_uri: URI of the container image to use for the model
- CodeTypes.NVIDIA_FLARE_V2_X (existing image)
code_execution_mode: CodeExecutionMode
- if CodeExecutionMode.DEFAULT requires the following additional parameters
container_image_uri: URI of the container image to use for the model
if CodeExecutionMode.AUTO_CONTAINER_NVFLARE, see CodeTypes.PYTHON_CODE below
- CodeTypes.PYTHON_CODE
- code_execution_mode: CodeExecutionMode = CodeExecutionMode.DEFAULT - The format the code is structured in
CodeTypes.PYTHON_CODE supports CodeExecutionMode.DEFAULT, CodeExecutionMode.AUTO_CONTAINER_SNIPPET, and CodeExecutionMode.AUTO_CONTAINER_FILE
CodeTypes.NVIDIA_FLARE_V2_X only supports CodeExecutionMode.AUTO_CONTAINER_NVFLARE
- if CodeExecutionMode.DEFAULT requires the following additional parameters
python_code: str - the python code to run
- CodeExecutionMode.AUTO_CONTAINER_SNIPPET requires the following additional parameters
code: str - the python code to run
- CodeExecutionMode.AUTO_CONTAINER_FILE or CodeExecutionMode.AUTO_CONTAINER_NVFLARE
- base_image: choose one of the following
base_image_uri: str - the base docker image to use for the container
or - python_version: str - the python version to use for the container - cuda_version: Optional[str] - the cuda version to use for the container
requirements_mode: Optional[RequirementMode] = RequirementMode.PYTHON_PIP - The format the requirements are in
requirements: List[str] - a list of requirements to install in the container, uses the pip/conda install format
- code_location: CodeLocation the location the code is passed to the user
- CodeLocation.DEFAULT
code: str - A string representation of the code directly embedded in the request
- CodeLocation.S3_MULTIPART_ZIP
folder_path: str | Path - the folder path to files on local disk which will be uploaded as a zip to s3
entry_point: str - name of the file to run first. Not used for auto container nvflare
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObject(**data)#
A CodeObject which exists on the platform
- property build_logs#
Logs when building the CodeObject, if building in the cloud
- property input_data_schemas: List[DataSchema]#
Return the DataSchema Dataclasses associated with input_data_schema_uids
Warning
The result of this function is cached. Be careful calling this function after making changes. All dataclasses must already exist on the platform before making this call.
- Returns:
- input_data_schemas: List[DataSchema]
Dataclasses representing the DataSchema
- property output_data_schemas: List[DataSchema]#
Return the DataSchema Dataclasses associated with output_data_schema_uids
Warning
The result of this function is cached. Be careful calling this function after making changes. All dataclasses must already exist on the platform before making this call.
- Returns:
- output_data_schemas: List[DataSchema]
Dataclasses representing the DataSchema
- property project: Project#
Return the Project Dataclass associated with project_uid
Warning
The result of this function is cached. Be careful calling this function after making changes. All dataclasses must already exist on the platform before making this call.
- Returns:
- project: Project
Dataclass representing the Project
- property creator: User#
Return the User Dataclass associated with creator_uid
Warning
The result of this function is cached. Be careful calling this function after making changes. All dataclasses must already exist on the platform before making this call.
- Returns:
- creator: User
Dataclass representing the User
- uid: str#
The unique ID of the CodeObject
- version: int | None#
The version of the CodeObject
- build_status: CodeObjectBuildStatus#
The build status of the CodeObject
- input_data_schema_uids: List[str] = []#
A list of uids of data schemas this CodeObject expects input datasets to adhere to.
- output_data_schema_uids: List[str] = []#
A list of uids of data schemas this CodeObject expects output datasets to adhere to.
- build_errors: List[str] | None#
Errors when building the CodeObject, if building in the cloud
- name: str#
The name of the CodeObject
- description: str#
The description of the CodeObject
- code_type: typing_extensions.Annotated[str, Field(alias='type')]#
The code type which corresponds to the CodeTypes enum
- base_version_uid: str | None = ''#
The first version of the CodeObject if multiple versions exist. You can also use add_version_if_exists=True when creating the code object in create_code_object if an existing code object with the same name exists
- config: dict | None#
Additional configuration of the CodeObject. The contents will differ based on the model_type and code_run_type.
See also
Examples
- CodeTypes.GENERALIZED_COMPUTE and CodeTypes.INTERACTIVE_CONTAINER
container_image_uri: URI of the container image to use for the model
- CodeTypes.NVIDIA_FLARE_V2_X (existing image)
code_execution_mode: CodeExecutionMode
- if CodeExecutionMode.DEFAULT requires the following additional parameters
container_image_uri: URI of the container image to use for the model
if CodeExecutionMode.AUTO_CONTAINER_NVFLARE, see CodeTypes.PYTHON_CODE below
- CodeTypes.PYTHON_CODE
- code_execution_mode: CodeExecutionMode = CodeExecutionMode.DEFAULT - The format the code is structured in
CodeTypes.PYTHON_CODE supports CodeExecutionMode.DEFAULT, CodeExecutionMode.AUTO_CONTAINER_SNIPPET, and CodeExecutionMode.AUTO_CONTAINER_FILE
CodeTypes.NVIDIA_FLARE_V2_X only supports CodeExecutionMode.AUTO_CONTAINER_NVFLARE
- if CodeExecutionMode.DEFAULT requires the following additional parameters
python_code: str - the python code to run
- CodeExecutionMode.AUTO_CONTAINER_SNIPPET requires the following additional parameters
code: str - the python code to run
- CodeExecutionMode.AUTO_CONTAINER_FILE or CodeExecutionMode.AUTO_CONTAINER_NVFLARE
- base_image: choose one of the following
base_image_uri: str - the base docker image to use for the container
or - python_version: str - the python version to use for the container - cuda_version: Optional[str] - the cuda version to use for the container
requirements_mode: Optional[RequirementMode] = RequirementMode.PYTHON_PIP - The format the requirements are in
requirements: List[str] - a list of requirements to install in the container, uses the pip/conda install format
- code_location: CodeLocation the location the code is passed to the user
- CodeLocation.DEFAULT
code: str - A string representation of the code directly embedded in the request
- CodeLocation.S3_MULTIPART_ZIP
folder_path: str | Path - the folder path to files on local disk which will be uploaded as a zip to s3
entry_point: str - name of the file to run first. Not used for auto container nvflare
- creator_uid: str#
The UID of the creator of this dataclass on the system
- created_at: str#
When this dataclass was created on the system
- input_data_schema_names: List[str]#
The input_data_schema names
- output_data_schema_names: List[str]#
The output_data_schema names
- project_name: str#
The project name
- creator_name: str#
The creator name
- wait_for_build(timeout_seconds: int = 900, poll_frequency: int = 30, print_progress: bool = True)#
Wait for the asynchronous CodeObject to finish building
- Parameters:
- timeout_seconds: int = 900
How many seconds to wait before timing out. Maximum of 1800.
- poll_frequency: int = 30
How frequent to check the status, in seconds
- print_progress: bool = True
Whether to print how long has elapsed since the start of the wait
- Returns:
- code_object: CodeObject
Dataclass representing the CodeObject
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectRunInput(*args, **kwargs)#
Bases:
rhino_health.lib.dataclass.RhinoBaseModel
Input parameters for running generalized code with multiple input and/or output datasets per container
See also
- code_object_uid: str#
The unique ID of the CodeObject
- run_params: str | None = '{}'#
The run params code you want to run on the datasets
- timeout_seconds: int = 600#
The time before a timeout is declared for the run
- secret_run_params: str | None#
The secrets for the CodeObject
- external_storage_file_paths: List[str] | None#
The s3 bucket paths of files to be used in the run
- sync: bool = False#
Highly recommended to use the default parameter
- input_dataset_uids: List[List[str]]#
A list of lists of the input dataset uids.
[[first_dataset_for_first_run, second_dataset_for_first_run …], [first_dataset_for_second_run, second_dataset_for_second_run …], …] for N runs
Examples
Suppose we have the following CodeObject with 2 Input Data Schemas:
- CodeObject
DataSchema 1
DataSchema 2
We want to run the CodeObject over two sites: Applegate and Bridgestone
The user passes in dataset UIDs for Datasets A, B, C, and D in the following order:
[[Dataset A, Dataset B], [Dataset C, Dataset D]]
The model will then be run over both sites with the following datasets passed to generalized compute:
- Site A - Applegate:
Dataset A - DataSchema 1
Dataset B - DataSchema 2
- Site B - Bridgestone:
Dataset C - DataSchema 1
Dataset D - DataSchema 2
- output_dataset_naming_templates: List[str] | None#
A list of string naming templates used to name the output datasets at each site. You can use parameters in each template surrounded by double brackets
{{parameter}}
which will then be replaced by their corresponding values.- Parameters:
- workgroup_name:
The name of the workgroup the CodeObject belongs to.
- workgroup_uid:
The name of the workgroup the CodeObject belongs to.
- code_object_name:
The CodeObject name
- input_dataset_names.n:
The name of the nth input dataset, (zero indexed)
- input_sal_names.n:
The name of the nth input Secure Access List (if a SAL is used as an input in Interactive Containers), (zero indexed)
- input_names.n:
The name of the nth input, whether dataset or SAL, (zero indexed)
Examples
Suppose we have two input datasets, named “First Dataset” and “Second Dataset” and our CodeObject has two outputs:
output_dataset_naming_templates = [“{{input_dataset_names.0}} - Train”,“{{input_dataset_names.1}} - Test”]After running Generalized Compute, we will save the two outputs as “First Dataset - Train” and “Second Dataset - Test”
- classmethod warn_on_usage_of_obsolete_arg(value)#
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectRunAsyncResponse(**data)#
Bases:
CodeObjectRunResponse
An asynchronous code run response
- property code_run#
Return the CodeRun associated with this CodeObject
Warning
The result of this function is cached. Be careful calling this function after making changes
- Returns:
- code_run: CodeRun
Dataclass representing the CodeRun
- task_uids: List[str]#
- status: str#
The status of the run
- output_dataset_uids: List[str] | None = []#
A list of output dataset uids for the run
- code_run_uid: str | None#
The UID of the model result
- wait_for_completion(*args, **kwargs)#
Wait for the asynchronous Code Run to complete, convenience function call to the same function on the CodeRun object.
- Returns:
- code_run: CodeRun
Dataclass representing the CodeRun of the CodeObject
See also
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectRunSyncResponse(**data)#
Bases:
CodeObjectRunResponse
A synchronous code run response
- property code_run#
Return the CodeRun associated with this CodeObject
Warning
The result of this function is cached. Be careful calling this function after making changes
- Returns:
- code_run: CodeRun
Dataclass representing the CodeRun
- errors: List[Any] | None = []#
- warnings: List[Any] | None = []#
- status: str#
The status of the run
- output_dataset_uids: List[str] | None = []#
A list of output dataset uids for the run
- code_run_uid: str | None#
The UID of the model result
- wait_for_completion(*args, **kwargs)#
Wait for the asynchronous Code Run to complete, convenience function call to the same function on the CodeRun object.
- Returns:
- code_run: CodeRun
Dataclass representing the CodeRun of the CodeObject
See also
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.ModelTrainInput(**data)#
Bases:
rhino_health.lib.dataclass.RhinoBaseModel
Input for training an NVFlare Model
See also
- code_object_uid: str#
The unique ID of the CodeObject
- input_dataset_uids: List[str]#
A list of the input Dataset uids
- validation_dataset_uids: List[str]#
A list of the Dohort uids for validation
- validation_datasets_inference_suffix: str#
The suffix given to all output datasets
- simulate_federated_learning: typing_extensions.Annotated[bool, Field(alias='one_fl_client_per_dataset')]#
Run simulated federated learning on the same on-prem installation by treating each dataset as a site
- config_fed_server: str | None#
The config for the federated server
- config_fed_client: str | None#
The config for the federated client
- secrets_fed_server: str | None#
The secrets for the federated server
- secrets_fed_client: str | None#
The secrets for the federated client
- external_storage_file_paths: List[str] | None#
The s3 bucket paths of files to be used in the run
- timeout_seconds: int#
The time before a timeout is declared for the run
- class rhino_health.lib.endpoints.code_object.code_object_dataclass.ModelTrainAsyncResponse(**data)#
Bases:
CodeRunWaitMixin
Response of training an NVFlare Model .. warning:: This feature is under development and the interface may change
- property code_run#
Return the CodeRun associated with the NVFlare training
Warning
The result of this function is cached. Be careful calling this function after making changes
- Returns:
- code_run: CodeRun
Dataclass representing the CodeRun
- status: str#
The status of the run
- code_run_uid: str | None#
The UID of the model result
- wait_for_completion(*args, **kwargs)#
Wait for the asynchronous Code Run to complete, convenience function call to the same function on the CodeRun object.
- Returns:
- code_run: CodeRun
Dataclass representing the CodeRun of the CodeObject
See also