:py:mod:`rhino_health.lib.endpoints.code_object.code_object_dataclass` ====================================================================== .. py:module:: rhino_health.lib.endpoints.code_object.code_object_dataclass Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeExecutionMode rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeFormat rhino_health.lib.endpoints.code_object.code_object_dataclass.RequirementMode rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeTypes rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectBuildStatus rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectCreateInput rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObject rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectRunInput rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectRunAsyncResponse rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeObjectRunSyncResponse rhino_health.lib.endpoints.code_object.code_object_dataclass.ModelTrainInput rhino_health.lib.endpoints.code_object.code_object_dataclass.ModelTrainAsyncResponse .. py:class:: CodeExecutionMode Bases: :py:obj:`str`, :py:obj:`enum.Enum` A mode the CodeObject will run in .. !! processed by numpydoc !! .. py:attribute:: DEFAULT :value: 'default' .. py:attribute:: AUTO_CONTAINER_NVFLARE :value: 'nvflare' .. py:attribute:: AUTO_CONTAINER_SNIPPET :value: 'snippet' .. py:attribute:: AUTO_CONTAINER_FILE :value: 'file' .. py:class:: CodeFormat Bases: :py:obj:`str`, :py:obj:`enum.Enum` A format the code is stored and uploaded to the system .. !! processed by numpydoc !! .. py:attribute:: DEFAULT :value: 'single_non_binary_file' .. py:attribute:: S3_MULTIPART_ZIP :value: 's3_multipart_zip' .. py:class:: RequirementMode Bases: :py:obj:`str`, :py:obj:`enum.Enum` The format the requirements are in .. !! processed by numpydoc !! .. py:attribute:: PYTHON_PIP :value: 'python_pip' .. py:attribute:: ANACONDA_ENVIRONMENT :value: 'anaconda_environment' .. py:attribute:: ANACONDA_SPECFILE :value: 'anaconda_specfile' .. py:class:: CodeTypes Bases: :py:obj:`str`, :py:obj:`enum.Enum` Supported CodeObject Types .. !! processed by numpydoc !! .. py:attribute:: GENERALIZED_COMPUTE :value: 'Generalized Compute' .. py:attribute:: NVIDIA_FLARE_V2_0 :value: 'NVIDIA FLARE v2.0' .. py:attribute:: NVIDIA_FLARE_V2_2 :value: 'NVIDIA FLARE v2.2' .. py:attribute:: NVIDIA_FLARE_V2_3 :value: 'NVIDIA FLARE v2.3' .. py:attribute:: NVIDIA_FLARE_V2_4 :value: 'NVIDIA FLARE v2.4' .. py:attribute:: PYTHON_CODE :value: 'Python Code' .. py:attribute:: INTERACTIVE_CONTAINER :value: 'Interactive Container' .. py:class:: CodeObjectBuildStatus Bases: :py:obj:`str`, :py:obj:`enum.Enum` The build status of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: NOT_STARTED :value: 'Not Started' .. py:attribute:: IN_PROGRESS :value: 'In Progress' .. py:attribute:: COMPLETE :value: 'Complete' .. py:attribute:: ERROR :value: 'Error' .. py:class:: CodeObjectCreateInput(**data) Bases: :py:obj:`rhino_health.lib.dataclass.RhinoBaseModel` Input arguments for creating CodeObject .. !! processed by numpydoc !! .. py:attribute:: name :type: str The name of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: description :type: str The description of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: input_data_schema_uids :type: List[str] :value: [] A list of uids of data schemas this CodeObject expects input datasets to adhere to. .. !! processed by numpydoc !! .. py:attribute:: output_data_schema_uids :type: List[Optional[str]] :value: [] A list of uids of data schemas this CodeObject expects output datasets to adhere to. .. !! processed by numpydoc !! .. py:attribute:: project_uid :type: typing_extensions.Annotated[str, Field(alias='project')] The CodeObject project .. !! processed by numpydoc !! .. py:attribute:: code_type :type: typing_extensions.Annotated[str, Field(alias='type')] The code type which corresponds to the CodeTypes enum .. seealso:: :obj:`rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeTypes` .. .. !! processed by numpydoc !! .. py:attribute:: base_version_uid :type: Optional[str] :value: '' 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 .. !! processed by numpydoc !! .. py:attribute:: config :type: Optional[dict] Additional configuration of the CodeObject. The contents will differ based on the model_type and code_run_type. .. seealso:: :obj:`rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeTypes` .. :obj:`rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeExecutionMode` .. .. rubric:: 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_format: CodeFormat the format used to pass in the code - CodeFormat.DEFAULT - code: str - the python code to run - CodeFormat.S3_MULTIPART_ZIP - folder_path: str | Path - the folder path to files - entry_point: str - name of the file to run first. Not used for auto container nvflare .. !! processed by numpydoc !! .. py:class:: CodeObject(**data) A CodeObject which exists on the platform .. !! processed by numpydoc !! .. py:property:: build_logs Logs when building the CodeObject, if building in the cloud .. !! processed by numpydoc !! .. py:property:: input_data_schemas :type: 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 .. py:property:: output_data_schemas :type: 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 .. py:property:: project :type: 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 .. py:property:: creator :type: 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 .. py:attribute:: uid :type: str The unique ID of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: version :type: Optional[int] The version of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: build_status :type: CodeObjectBuildStatus The build status of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: input_data_schema_uids :type: List[str] :value: [] A list of uids of data schemas this CodeObject expects input datasets to adhere to. .. !! processed by numpydoc !! .. py:attribute:: output_data_schema_uids :type: List[str] :value: [] A list of uids of data schemas this CodeObject expects output datasets to adhere to. .. !! processed by numpydoc !! .. py:attribute:: build_errors :type: Optional[List[str]] Errors when building the CodeObject, if building in the cloud .. !! processed by numpydoc !! .. py:attribute:: name :type: str The name of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: description :type: str The description of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: code_type :type: typing_extensions.Annotated[str, Field(alias='type')] The code type which corresponds to the CodeTypes enum .. seealso:: :obj:`rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeTypes` .. .. !! processed by numpydoc !! .. py:attribute:: base_version_uid :type: Optional[str] :value: '' 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 .. !! processed by numpydoc !! .. py:attribute:: config :type: Optional[dict] Additional configuration of the CodeObject. The contents will differ based on the model_type and code_run_type. .. seealso:: :obj:`rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeTypes` .. :obj:`rhino_health.lib.endpoints.code_object.code_object_dataclass.CodeExecutionMode` .. .. rubric:: 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_format: CodeFormat the format used to pass in the code - CodeFormat.DEFAULT - code: str - the python code to run - CodeFormat.S3_MULTIPART_ZIP - folder_path: str | Path - the folder path to files - entry_point: str - name of the file to run first. Not used for auto container nvflare .. !! processed by numpydoc !! .. py:attribute:: creator_uid :type: str The UID of the creator of this dataclass on the system .. !! processed by numpydoc !! .. py:attribute:: created_at :type: str When this dataclass was created on the system .. !! processed by numpydoc !! .. py:attribute:: input_data_schema_names :type: List[str] The input_data_schema names .. py:attribute:: output_data_schema_names :type: List[str] The output_data_schema names .. py:attribute:: project_name :type: str The project name .. py:attribute:: creator_name :type: str The creator name .. py:method:: 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 .. !! processed by numpydoc !! .. py:class:: CodeObjectRunInput(*args, **kwargs) Bases: :py:obj:`rhino_health.lib.dataclass.RhinoBaseModel` Input parameters for running generalized code with multiple input and/or output datasets per container .. seealso:: :obj:`rhino_health.lib.endpoints.code_object.code_object_endpoints.CodeObjectEndpoints.run_code_object` Example Usage .. !! processed by numpydoc !! .. py:attribute:: code_object_uid :type: str The unique ID of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: run_params :type: Optional[str] :value: '{}' The run params code you want to run on the datasets .. !! processed by numpydoc !! .. py:attribute:: timeout_seconds :type: int :value: 600 The time before a timeout is declared for the run .. !! processed by numpydoc !! .. py:attribute:: secret_run_params :type: Optional[str] The secrets for the CodeObject .. !! processed by numpydoc !! .. py:attribute:: external_storage_file_paths :type: Optional[List[str]] The s3 bucket paths of files to be used in the run .. !! processed by numpydoc !! .. py:attribute:: sync :type: bool :value: False Highly recommended to use the default parameter .. !! processed by numpydoc !! .. py:attribute:: input_dataset_uids :type: 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 .. rubric:: 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 .. !! processed by numpydoc !! .. py:attribute:: output_dataset_naming_templates :type: Optional[List[str]] 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) .. rubric:: 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" .. !! processed by numpydoc !! .. py:method:: warn_on_usage_of_obsolete_arg(value) :classmethod: .. py:class:: CodeObjectRunAsyncResponse(**data) Bases: :py:obj:`CodeObjectRunResponse` An asynchronous code run response .. !! processed by numpydoc !! .. py: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 .. !! processed by numpydoc !! .. py:attribute:: task_uids :type: List[str] .. py:attribute:: status :type: str The status of the run .. !! processed by numpydoc !! .. py:attribute:: output_dataset_uids :type: Optional[List[str]] :value: [] A list of output dataset uids for the run .. !! processed by numpydoc !! .. py:attribute:: code_run_uid :type: Optional[str] The UID of the model result .. !! processed by numpydoc !! .. py:method:: 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 .. seealso:: :obj:`rhino_health.lib.endpoints.code_run.code_run_dataclass.CodeRun` Response object :obj:`rhino_health.lib.endpoints.code_run.code_run_dataclass.CodeRun.wait_for_completion` Accepted parameters .. !! processed by numpydoc !! .. py:class:: CodeObjectRunSyncResponse(**data) Bases: :py:obj:`CodeObjectRunResponse` A synchronous code run response .. !! processed by numpydoc !! .. py: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 .. !! processed by numpydoc !! .. py:attribute:: errors :type: Optional[List[Any]] :value: [] .. py:attribute:: warnings :type: Optional[List[Any]] :value: [] .. py:attribute:: status :type: str The status of the run .. !! processed by numpydoc !! .. py:attribute:: output_dataset_uids :type: Optional[List[str]] :value: [] A list of output dataset uids for the run .. !! processed by numpydoc !! .. py:attribute:: code_run_uid :type: Optional[str] The UID of the model result .. !! processed by numpydoc !! .. py:method:: 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 .. seealso:: :obj:`rhino_health.lib.endpoints.code_run.code_run_dataclass.CodeRun` Response object :obj:`rhino_health.lib.endpoints.code_run.code_run_dataclass.CodeRun.wait_for_completion` Accepted parameters .. !! processed by numpydoc !! .. py:class:: ModelTrainInput(**data) Bases: :py:obj:`rhino_health.lib.dataclass.RhinoBaseModel` Input for training an NVFlare Model .. seealso:: :obj:`rhino_health.lib.endpoints.code_object.code_object_endpoints.CodeObjectEndpoints.train_model` Example Usage .. !! processed by numpydoc !! .. py:attribute:: code_object_uid :type: str The unique ID of the CodeObject .. !! processed by numpydoc !! .. py:attribute:: input_dataset_uids :type: List[str] A list of the input Dataset uids .. !! processed by numpydoc !! .. py:attribute:: validation_dataset_uids :type: List[str] A list of the Dohort uids for validation .. !! processed by numpydoc !! .. py:attribute:: validation_datasets_inference_suffix :type: str The suffix given to all output datasets .. !! processed by numpydoc !! .. py:attribute:: simulate_federated_learning :type: 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 .. !! processed by numpydoc !! .. py:attribute:: config_fed_server :type: Optional[str] The config for the federated server .. !! processed by numpydoc !! .. py:attribute:: config_fed_client :type: Optional[str] The config for the federated client .. !! processed by numpydoc !! .. py:attribute:: secrets_fed_server :type: Optional[str] The secrets for the federated server .. !! processed by numpydoc !! .. py:attribute:: secrets_fed_client :type: Optional[str] The secrets for the federated client .. !! processed by numpydoc !! .. py:attribute:: external_storage_file_paths :type: Optional[List[str]] The s3 bucket paths of files to be used in the run .. !! processed by numpydoc !! .. py:attribute:: timeout_seconds :type: int The time before a timeout is declared for the run .. !! processed by numpydoc !! .. py:class:: ModelTrainAsyncResponse(**data) Bases: :py:obj:`CodeRunWaitMixin` Response of training an NVFlare Model .. warning:: This feature is under development and the interface may change .. !! processed by numpydoc !! .. py: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 .. !! processed by numpydoc !! .. py:attribute:: status :type: str The status of the run .. !! processed by numpydoc !! .. py:attribute:: code_run_uid :type: Optional[str] The UID of the model result .. !! processed by numpydoc !! .. py:method:: 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 .. seealso:: :obj:`rhino_health.lib.endpoints.code_run.code_run_dataclass.CodeRun` Response object :obj:`rhino_health.lib.endpoints.code_run.code_run_dataclass.CodeRun.wait_for_completion` Accepted parameters .. !! processed by numpydoc !!