> For the complete documentation index, see [llms.txt](https://docs.rhinofcp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rhinofcp.com/rhino-sdk/running-a-generalized-compute-code-object-using-the-rhino-sdk/creating-a-generalized-compute-code-object-using-the-rhino-sdk.md).

# Creating a Generalized Compute Code Object Using the Rhino SDK

This article explains how to use the SDK to create a new Generalized Compute Code Object.

{% hint style="info" %}
If you want to know how to create a new Generalized Compute Code Object using the SDK, see [Creating and Running a New Generalized Compute Code Object](/creating-and-running-code-objects/creating-and-running-a-new-generalized-compute-code-object.md).
{% endhint %}

{% hint style="info" %}
If your dataset contains sensitive data, then by default, all output datasets are considered to be sensitive. For more information on this, including how to mark which data is sensitive and which is not, please see [Sensitive Datasets](/datasets/sensitive-datasets.md).
{% endhint %}

## Prerequisites

Before starting this process, you should have already:

1. Created a Project using the Rhino SDK or the User Interface (UI).
2. Created an Input Data Schema using the Rhino SDK or UI.
3. \[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

```python
import rhino_health as rh
from rhino_health.lib.endpoints.code.code_objects_dataclass import (
    CodeObject,
    CodeObjectCreateInput,
    CodeTypes,
    CodeRunType
)
import getpass
```

{% hint style="info" %}
Remember to change all lines with `CHANGE_ME` comments above them in all the blocks below.
{% endhint %}

## Log into the Rhino SDK using your FCP Credentials

Your username will be the email address you log into the Rhino FCP platform with.

```python
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 with client storage setup, please refer to [Mounting Storage to Your Rhino Client](/getting-started/quick-start-guide/mounting-storage-to-your-rhino-client.md)

### 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. For guidance related to client storage setup, please refer to [Mounting Storage to Your Rhino Client](/getting-started/quick-start-guide/mounting-storage-to-your-rhino-client.md)

You can also retrieve each object's UUID by following the instructions here: [Frequently Asked Questions (FAQs)](/frequently-asked-questions/frequently-asked-questions-faqs.md)

```python
# 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.

```python
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.
