citrine.seeding.find_or_create module

citrine.seeding.find_or_create.create_or_update(*, collection: Collection[CreationType], resource: CreationType) CreationType

Update a resource of a given name belonging to a collection.

Create it if it doesn’t exist. If collection already contains a resource with the same name it will be updated. If there are multiple resources with the same name it will throw an error.

Parameters:
  • collection (Collection[CreationType]) – Collection within which you want to update or create a resource

  • resource (CreationType) – Resource that you want to create or update.

Returns:

Registered updated or created resource.

Return type:

CreationType

citrine.seeding.find_or_create.find_collection(*, collection: Collection[T], name: str) T | None

Looks through the pages of a collection for a resource with the specified name.

Returns it, or if not found, returns None

citrine.seeding.find_or_create.find_or_create_dataset(*, dataset_collection: DatasetCollection, dataset_name: str, raise_error: bool = False) Dataset

Tries to find a dataset by name (returns first hit).

If not found, creates a new dataset with the given name

citrine.seeding.find_or_create.find_or_create_project(*, project_collection: ProjectCollection, project_name: str, raise_error: bool = False) Project

Tries to find a project by name (returns first hit).

If not found, creates a new project with the given name

citrine.seeding.find_or_create.find_or_create_team(*, team_collection: TeamCollection, team_name: str, raise_error: bool = False) Team

Tries to find a team by name (returns first hit).

If not found, creates a new team with the given name

citrine.seeding.find_or_create.get_by_name_or_create(*, collection: Collection[T], name: str, default_provider: Callable[[...], T]) T

Tries to find a collection by its name (returns first hit).

If not found, implements default_provider

citrine.seeding.find_or_create.get_by_name_or_raise_error(*, collection: Collection[T], name: str) T

Tries to find a collection by its name (returns first hit).

If not found, raises error