Skip to content

Share projects

This example demonstrates how you can create and share a project with another user using the MLOps Python client.

Before you begin

  • You will need the values for the following constants in order to successfully carry out the task. Contact your administrator to obtain deployment specific values.
Value Description
MLOPS_API_URL Usually: Defines the URL for the MLOps Gateway component. You can verify the correct URL by navigating to the API URL in your browser. It should provide a page with a list of available routes.
TOKEN_ENDPOINT_URL https://mlops.keycloak.domain/auth/realms/[fill-in-realm-name]/protocol/openid-connect/token Defines the token endpoint URL of the Identity Provider. This uses Keycloak as the Identity Provider. Keycloak Realm should be provided.
REFRESH_TOKEN <your-refresh-token> Defines the user's refresh token
CLIENT_ID <your-client-id> Sets the client id for authentication. This is the client you will be using to connect to MLOps.
PROJECT_NAME SharedProjectExample Defines a project name that the script will be using.
USER_TO_SHARE_WITH <user-id> Defines a user to share the project with.

The following steps demonstrate how you can use MLOps Python client to create and share a project with another user.

  1. Download the file.

  2. Change the values of the following constants in your file as given in the preceding data table.
        ### Constants
        ### Constants
        MLOPS_API_URL = ""
        PROJECT_NAME = "SharedProjectExample"
        USER_TO_SHARE_WITH = "<user-id>"
  3. Run the file.

  4. Navigate to MLOps to view the created project SharedProjectsExample. Then click the plus icon to see the users the project has been shared with.

    Sharing a project in MLOps

  5. In the Share project: SharedProjectExample side panel, you can see that the project has been shared with the specified user with Default permission.

    Sharing a project in MLOps - users

Example walkthrough

The following steps provide a walkthrough of each of the sections in the file.

  1. Set up the token provider using an existing refresh token.

  2. Set up the MLOps client.

  3. Get a user to share the project with.
        user_for_sharing: mlops.StorageUser = (
  4. Get the roles in MLOps.
        roles_raw: List[mlops.StorageRole] ={}).role
        roles = {r.display_name: for r in roles_raw}


    Two basic roles are available for default installations of MLOps:

    • Default - Read/Write access

    • Reader - only Read access

  5. Create a project to share.
        project: mlops.StorageProject =
  6. Finally, restrict the role of the user to either Default or Reader, and share the created project with the specified user.