Use Cases
- class datarobot.UseCase(id, name, created_at, created, updated_at, updated, models_count, projects_count, datasets_count, notebooks_count, applications_count, playgrounds_count, vector_databases_count, members, description=None, owners=None)
Representation of a Use Case.
Examples
import datarobot with UseCase.get("2348ac"): print(f"The current use case is {dr.Context.use_case}")
- Attributes:
- idstr
The ID of the Use Case.
- namestr
The name of the Use Case.
- descriptionstr
The description of the Use Case. Nullable.
- created_atstr
The timestamp generated at record creation.
- createdUseCaseUser
The user who created the Use Case.
- updated_atstr
The timestamp generated when the record was last updated.
- updatedUseCaseUser
The most recent user to update the Use Case.
- models_countint
The number of models in a Use Case.
- projects_countint
The number of projects in a Use Case.
- datasets_count: int
The number of datasets in a Use Case.
- notebooks_count: int
The number of notebooks in a Use Case.
- applications_count: int
The number of applications in a Use Case.
- playgrounds_count: int
The number of playgrounds in a Use Case.
- vector_databases_count: int
The number of vector databases in a Use Case.
- ownersList[UseCaseUser]
The most recent user to update the Use Case.
- membersList[UseCaseUser]
The most recent user to update the Use Case.
- get_uri()
- Returns:
- urlstr
Permanent static hyperlink to this Use Case.
- Return type:
str
- classmethod get(use_case_id)
Gets information about a Use Case.
- Parameters:
- use_case_idstr
The identifier of the Use Case you want to load.
- Returns:
- use_caseUseCase
The queried Use Case.
- Return type:
- classmethod list(search_params=None)
Returns the Use Cases associated with this account.
- Parameters:
- search_paramsdict, optional.
If not None, the returned projects are filtered by lookup. Currently, you can query use cases by:
offset
- The number of records to skip over. Default 0.limit
- The number of records to return in the range from 1 to 100. Default 100.search
- Only return Use Cases with names that match the given string.project_id
- Only return Use Cases associated with the given project ID.application_id
- Only return Use Cases associated with the given app.orderBy
- The order to sort the Use Cases.
orderBy
queries can use the following options:id
or-id
name
or-name
description
or-description
projects_count
or-projects_count
datasets_count
or-datasets_count
notebooks_count
or-notebooks_count
applications_count
or-applications_count
created_at
or-created_at
created_by
or-created_by
updated_at
or-updated_at
updated_by
or-updated_by
- Returns:
- use_caseslist of UseCase instances
Contains a list of Use Cases associated with this user account.
- Raises:
- TypeError
Raised if
search_params
parameter is provided, but is not of supported type.
- Return type:
List
[UseCase
]
- classmethod create(name=None, description=None)
Create a new Use Case.
- Parameters:
- namestr
Optional. The name of the new Use Case.
- description: str
The description of the new Use Case. Optional.
- Returns:
- use_caseUseCase
The created Use Case.
- Return type:
- classmethod delete(use_case_id)
Delete a Use Case.
- Parameters:
- use_case_idstr
The ID of the Use Case to be deleted.
- Return type:
None
- update(name=None, description=None)
Update a Use Case’s name or description.
- Parameters:
- namestr
The updated name of the Use Case.
- descriptionstr
The updated description of the Use Case.
- Returns:
- use_caseUseCase
The updated Use Case.
- Return type:
- add(entity=None, entity_type=None, entity_id=None)
Add an entity (project, dataset, etc.) to a Use Case. Can only accept either an entity or an entity type and entity ID, but not both.
Projects and Applications can only be linked to a single Use Case. Datasets can be linked to multiple Use Cases.
There are some prerequisites for linking Projects to a Use Case which are explained in the user guide.
- Parameters:
- entityUnion[UseCaseReferenceEntity, Project, Dataset, Application]
An existing entity to be linked to this Use Case. Cannot be used if entity_type and entity_id are passed.
- entity_typeUseCaseEntityType
The entity type of the entity to link to this Use Case. Cannot be used if entity is passed.
- entity_idstr
The ID of the entity to link to this Use Case. Cannot be used if entity is passed.
- Returns:
- use_case_reference_entityUseCaseReferenceEntity
The newly created reference link between this Use Case and the entity.
- Return type:
- remove(entity=None, entity_type=None, entity_id=None)
Remove an entity from a Use Case. Can only accept either an entity or an entity type and entity ID, but not both.
- Parameters:
- entityUnion[UseCaseReferenceEntity, Project, Dataset, Application]
An existing entity instance to be removed from a Use Case. Cannot be used if entity_type and entity_id are passed.
- entity_typeUseCaseEntityType
The entity type of the entity to link to this Use Case. Cannot be used if entity is passed.
- entity_idstr
The ID of the entity to link to this Use Case. Cannot be used if entity is passed.
- Return type:
None
Share this Use Case with or remove access from one or more user(s).
- Parameters:
- rolesList[SharingRole]
A list of
SharingRole
instances, each of which references a user and a role to be assigned.Currently, the only supported roles for Use Cases are OWNER, EDITOR, and CONSUMER, and the only supported SHARING_RECIPIENT_TYPE is USER.
To remove access, set a user’s role to
datarobot.enums.SHARING_ROLE.NO_ROLE
.
- Return type:
None
Examples
The
SharingRole
class is needed in order to share a Use Case with one or more users.For example, suppose you had a list of user IDs you wanted to share this Use Case with. You could use a loop to generate a list of
SharingRole
objects for them, and bulk share this Use Case.>>> from datarobot.models.use_cases.use_case import UseCase >>> from datarobot.models.sharing import SharingRole >>> from datarobot.enums import SHARING_ROLE, SHARING_RECIPIENT_TYPE >>> >>> user_ids = ["60912e09fd1f04e832a575c1", "639ce542862e9b1b1bfa8f1b", "63e185e7cd3a5f8e190c6393"] >>> sharing_roles = [] >>> for user_id in user_ids: ... new_sharing_role = SharingRole( ... role=SHARING_ROLE.CONSUMER, ... share_recipient_type=SHARING_RECIPIENT_TYPE.USER, ... id=user_id, ... ) ... sharing_roles.append(new_sharing_role) >>> use_case = UseCase.get(use_case_id="5f33f1fd9071ae13568237b2") >>> use_case.share(roles=sharing_roles)
Similarly, a
SharingRole
instance can be used to remove a user’s access if therole
is set toSHARING_ROLE.NO_ROLE
, like in this example:>>> from datarobot.models.use_cases.use_case import UseCase >>> from datarobot.models.sharing import SharingRole >>> from datarobot.enums import SHARING_ROLE, SHARING_RECIPIENT_TYPE >>> >>> user_to_remove = "[email protected]" ... remove_sharing_role = SharingRole( ... role=SHARING_ROLE.NO_ROLE, ... share_recipient_type=SHARING_RECIPIENT_TYPE.USER, ... username=user_to_remove, ... ) >>> use_case = UseCase.get(use_case_id="5f33f1fd9071ae13568237b2") >>> use_case.share(roles=[remove_sharing_role])
Retrieve access control information for this Use Case.
- Parameters:
- offsetOptional[int]
The number of records to skip over. Optional. Default is 0.
- limit: Optional[int]
The number of records to return. Optional. Default is 100.
- id: Optional[str]
Return the access control information for a user with this user ID. Optional.
- Return type:
List
[SharingRole
]
- list_projects()
List all projects associated with this Use Case.
- Returns:
- projectsList[Project]
All projects associated with this Use Case.
- Return type:
List
[TypeVar
(T
)]
- list_datasets()
List all datasets associated with this Use Case.
- Returns:
- datasetsList[Dataset]
All datasets associated with this Use Case.
- Return type:
List
[TypeVar
(T
)]
- list_applications()
List all applications associated with this Use Case.
- Returns:
- applicationsList[Application]
All applications associated with this Use Case.
- Return type:
List
[TypeVar
(T
)]
- classmethod from_data(data)
Instantiate an object of this class using a dict.
- Parameters:
- datadict
Correctly snake_cased keys and their values.
- Return type:
TypeVar
(T
, bound= APIObject)
- classmethod from_server_data(data, keep_attrs=None)
Instantiate an object of this class using the data directly from the server, meaning that the keys may have the wrong camel casing
- Parameters:
- datadict
The directly translated dict of JSON from the server. No casing fixes have taken place
- keep_attrsiterable
List, set or tuple of the dotted namespace notations for attributes to keep within the object structure even if their values are None
- Return type:
TypeVar
(T
, bound= APIObject)
- open_in_browser()
Opens class’ relevant web browser location. If default browser is not available the URL is logged.
Note: If text-mode browsers are used, the calling process will block until the user exits the browser.
- Return type:
None
- class datarobot.models.use_cases.use_case.UseCaseUser(id, full_name=None, email=None, userhash=None, username=None)
Representation of a Use Case user.
- Attributes:
- idstr
The id of the user.
- full_namestr
The full name of the user. Optional.
- emailstr
The email address of the user. Optional.
- userhashstr
User’s gravatar hash. Optional.
- usernamestr
The username of the user. Optional.
- class datarobot.models.use_cases.use_case.UseCaseReferenceEntity(id, entity_type, entity_id, use_case_id, created_at, created, is_deleted)
An entity associated with a Use Case.
- Attributes:
- entity_typeUseCaseEntityType
The type of the entity.
- use_case_idstr
The Use Case this entity is associated with.
- idstr
The ID of the entity.
- created_atstr
The date and time this entity was linked with the Use Case.
- is_deletedbool
Whether or not the linked entity has been deleted.
- createdUseCaseUser
The user who created the link between this entity and the Use Case.