rhino_health.lib.endpoints.code_run.code_run_endpoints
#
Module Contents#
Classes#
Endpoints for interacting with CodeRuns |
- class rhino_health.lib.endpoints.code_run.code_run_endpoints.CodeRunEndpoints(session)#
Bases:
LTSCodeRunEndpoints
Endpoints for interacting with CodeRuns
- get_code_run(code_run_uid: str)#
Returns a CodeRun dataclass
- Parameters:
- code_run_uid: str
UID for the CodeRun
- Returns:
- code_run: CodeRun
CodeRun dataclass
Examples
>>> session.code_object.get_code_run(code_run_uid) CodeRun()
- get_model_params(code_run_uid: str, model_weights_files: List[str] | None = None) io.BytesIO #
Returns the contents of one or more model params file(s) associated with a model result.
The return value is an open binary file-like object, which can be read or written to a file.
The contents are for a single file. This is either the model params file if there was only one available or selected, or a Zip file containing multiple model params files.
- Parameters:
- code_run_uid: str
UID for the CodeRun
- model_weights_files: List(str)
List of paths within S3 of model weight files to download. If multiple files are supplied, download as zip. If the argument is not specified, download all model weight files found for the given CodeRun.
- Returns:
- model_params: BytesIO
A Python BytesIO Buffer
Examples
>>> with open("my_output_file.out", "wb") as output_file: >>> model_params_buffer = session.code_run.get_model_params(code_run_uid, model_weights_files) >>> output_file.write(model_params_buffer.getbuffer())
- halt_code_run(code_run_uid: str)#
Send a halting request to a Code Run.
This triggers the halting process but does not wait for halting to complete.
If triggering the halting process fails, a message specifying the error is returned.
Warning
This feature is under development and the interface may change
- Parameters:
- code_run_uid: str
UID of the CodeRun to halt.
- Returns:
- json response in the format of:
- “status”: the request’s status code -
200: valid request, halting innitiated.
400: invalid request, the model can not be halted, or does not exist.
500: error while initiating halting.
- “data”: message specifying if the halting was initiated or failed. In case the request failed,
the error message is also displayed.
Examples
>>> session.code_run.halt_code_run(code_run_uid)
- run_inference(code_run_uid: str, validation_dataset_uids: List[str], validation_datasets_suffix: str, timeout_seconds: int)#
Start running inference on one or more datasets using a previously trained NVFlare Model.
- Parameters:
- code_run_uid: str
UID for the code run
- validation_dataset_uids: List[str]
List of dataset UIDs to run inference on
- validation_datasets_suffix: str
Suffix for the validation datasets
- timeout_seconds: int
Timeout in seconds
- Returns:
- ModelInferenceAsyncResponse()
Examples
>>> s = session.code_run.run_inference(code_run_uid, validation_dataset_uids, validation_datasets_suffix, timeout_seconds) >>> s.code_run() # Get the asynchronous result >>> s.code_run_uid # Get the code run UID See Also -------- rhino_health.lib.endpoints.code_object.code_object_dataclass.ModelInferenceAsyncResponse : ModelInferenceAsyncResponse Dataclass