This article explains how to create a new Generalized Compute code objects using two different methods:
- Using the FCP user interface (UI), and
- Using the SDK
Using the User Interface to Create a New Generalized Compute Code Object
Follow these steps to use the UI to create a new Generalized Compute Code Object.
- Go to the main project's page and select your project.
- Select Code from the menu on the left to open the Code Objects page.
- Select the Create New Code Object button to open the Create New Code Object page.
- Select Generalized Compute as the Code Object Type. The page changes to show the fields needed for this object type.
- Enter information in the following fields.
Field/Button | Description |
Name | Indicates the name you want to provide for the code object. |
Description | Provides a brief summary of what the code object does. |
Input (including three-dot menu items) | Indicates the file(s) needed for the code object to run properly. Your selection here will affect which Dataset(s) can be selected as input when triggering a Code Run with this Code Object You can enter one or more input files, such as schemas, configuration files, or others. File(s) can be in DICOM, JSON, and or text formats.
|
Output | Indicates the output file(s) produced when the code object run. You can enter one or more output files. Files can be in DICOM, JSON, and or text formats.
|
Container | Specifies the name of the Docker container you would like to execute when running this Code Object. This will either be a container image created by someone from your workgroup that is available on your ECR or an image provided by Rhino Health. If you need a refresher on pushing containers to your ECR, please refer to Pushing Containers to the ECR. |
- After you've completed your details, select the Create New Code button to create the new Code Object.
- The code object appears on the Code Object page.
Creating a New Generalized Compute Code Object Version
To create a new version, complete the following steps.
- Go to the page that has the original object you want to create a new version of.
- In the upper right corner of the box where your original object is, select the + New Version button.
- A new window appears that allows you to create a new version of your object.
Creating a New Version in Every Interface within the Rhino FCP UI
Below is a GIF showing all the interfaces within the Rhino FCP application where you can create a new Version. It displays the Schemas, Cohorts, and Models pages and the + New Version button you will press to create that new version of the schema, cohort, or model you are looking to create.
Using the SDK to Create a New Generalized Compute Code Object
Prerequisites
Before starting this process, you should have already:
- Created a Project using the Rhino SDK or the User Interface (UI).
- Created an Input Data Schema using the Rhino SDK or UI.
- [Optional] Created an Output Data Schema using the Rhino SDK or UI. If you choose not to create an output Data Schema, the system will auto-generate the Data Schema of the output for your Code.
Import your Python Dependencies
import rhino_health as rh from rhino_health.lib.endpoints.code.code_objects_dataclass import ( CodeObject, CodeObjectCreateInput, CodeTypes, CodeRunType ) import getpass
NOTE: Remember to change all lines with CHANGE_ME comments above them in all the blocks below. |
Log into the Rhino SDK using your FCP Credentials
Your username will be the email address you log into the Rhino FCP platform with.
print("Logging In") # CHANGE_ME: MY_USERNAME my_username = "MY_USERNAME" session = rh.login(username=my_username, password=getpass.getpass()) print("Logged In")
Getting Started: Creating Your Generalized Compute Code Object
To create Generalized Compute Code using the Rhino SDK, you will need to first push a container to your workgroup's ECR. Note the name you use for your container image while pushing; you will need to include it in your code below. You will also need your ECR workgroup. If you need help locating your ECR Workgroup, please refer to How can I find my ECR Workgroup Repository Name?
Get Supporting FCP Information Needed to Create Your Code Object
At this point, you will need the name of your project, your input Data Schema name, optionally your output Data Schema name, and your ECR URI. Your ECR URI can be retrieved from your FCP User Profile; for a reminder on how to do this, please refer to How can I find my ECR Workgroup Repository Name?
You can also retrieve each object's UUID by following the instructions here: How do I retrieve a Project's, Collaborator's, Data Schema's, Dataset's, Code Objects's, or Code Run's UUID?
# CHANGE_ME: YOUR_FCP_PROJECT_NAME
project = session.project.get_project_by_name('YOUR_FCP_PROJECT_NAME')
# CHANGE_ME: INPUT_SCHEMA_NAME & Possibly Version Number too
input_schema = session.project.get_data_schema_by_name('INPUT_SCHEMA_NAME', project_uid=project.uid, version=1)
# CHANGE_ME: OUTPUT_SCHEMA_NAME & Possibly Version Number too.
output_schema = session.project.get_data_schema_by_name('OUTPUT_SCHEMA_NAME', project_uid=project.uid, version=1)
# CHANGE_ME: ECR_WORKGROUP
base_ecr_uri = rh.lib.constants.ECRService.PROD_URL + "/ECR_WORKGROUP"
Create Your Generalized Compute CodeObject
Using the Container You Just Pushed
During the creation of your CodeObject
, you will provide a configuration similar to how a Code Object is created within the GUI. You will give the CodeObject
a name, description, input_data_schema_uids
, output_data_schema_uids
, project_uid
, code_object_type
, and the config
where you will provide the name of the container you just pushed.
code_object_params = CodeObjectCreateInput(
# CHANGE_ME: CODE_OBJECT_NAME
name = "CODE_OBJECT_NAME",
# CHANGE_ME: CODE_OBJECT_DESCRIPTION
description = "CODE_OBJECT_DESCRIPTION",
input_data_schema_uids = [input_schema.uid],
# output_schema.uid or None to auto-generate an output schema
output_data_schema_uids = [output_schema.uid],
project_uid = project.uid,
code_object_type = CodeTypes.GENERALIZED_COMPUTE,
# CHANGE_ME: CONTAINER_IMAGE_NAME
config = {
"container_image_uri": f"{base_ecr_uri}:CONTAINER_IMAGE_NAME"
}
)
code_object = session.code.create_code_object(code_object_params)
print(f"Got Code Object '{codeobject.name}' with UID {codeobject.uid}")
Getting Help
If you have received an error or run into any issues throughout the process, please reach out to support@rhinohealth.com for more assistance.