Creating New NVFlare Code using the Rhino FCP UI
Navigate to the Code (formerly Models) Page
Use the left-hand navigation menu to click the Code menu item
Add a New Code Object
Create a new model by clicking on the Create New Code Object button in the top-right corner
Enter your New Code Details
Fill in the following fields within the new modal window:
- Name: The name you would like to provide for your Code
- Description: A description that will help you understand the nature of the Code
- Type: NVIDIA FLARE 2.0, NVIDIA FLARE 2.2, NVIDIA FLARE 2.3, or NVIDIA FLARE 2.4
- Input Data Schema: The Data Schema of the input Datasets you will run against this Code. Note: Your selection here will affect what Dataset are selectable to be run with your Code when it comes to running your Code
- Output Data Schema: The Data Schema for the output Dataset that will be produced as a result of running this Code. You can also select the option to [Auto-generate Data Schema from Data]. For more information about auto-generating Data schemas, please refer to Auto-Generated Data Schemas.
- Container: The Docker container you would like to execute when running this Code. This will either be a container you have created yourself and pushed to your ECR or a stock ECR image provided by Rhino Health. If you need a refresher on pushing containers to your ECR, please refer to Pushing Containers to the ECR.
Selecting your NVFlare Container
When you click on the drop-down to select your container, you will be presented with two different sections that contain various container images:
- Workgroup Images: These will be all the containers you have pushed to your workgroup's ECR. If you have not pushed anything to your workgroups ECR, this will be blank
- Rhino Health Images: These are a few container images that Rhino Health provides to users as utilities to help users. Currently, there are no NVFlare images that are provided by default from Rhino Health. But for more information on the containers that Rhino Health does provide, please refer to What are these container images provided under the section Rhino Health Images when creating Code?
When you have completed adding all your NVFlare Code details, click the Create New Code button to create your new Code.
Creating a New NVFlare Code Version using the Rhino FCP UI
To create a new version, make sure you are on the page containing the original object you would like to create a new version of. In the box where your original object is in the upper right-hand corner, you should see a + New Version button, like the one shown below:
Click that button and a new dialog should appear that will allow 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.
Creating New NVFlare Code or a Code Version using the Rhino SDK
Prerequisites
Before starting this process, you should have already:
- Created a Project using the Rhino SDK or 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
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 NVFlare Code
To create NVFlare 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
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 workgroup name. Your ECR workgroup 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 Object'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 NVFlare Code Object using the Container You Just Pushed
During the creation of your CodeObject
, you will provide it with various pieces of data similar to how Code is created within the UI. 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 Infer Output Data Schema
output_data_schema_uids = [output_schema.uid],
project_uid = project.uid,
# CHANGE_ME: NVIDIA_FLARE_V2_0, depending on what version of NVFlare you want to use
code_type = CodeTypes.NVIDIA_FLARE_V2_0,
# OR code_type = CodeTypes.NVIDIA_FLARE_V2_2,
# OR code_type = CodeTypes.NVIDIA_FLARE_V2_3,
# OR code_type = CodeTypes.NVIDIA_FLARE_V2_4,
# 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 '{code_object.name}' with UID {code_object.uid}")
NOTE: If you have received an error or run into any issues throughout the process, please reach out to support@rhinohealth.com for more assistance.