bailo.helper package

Note

All helper methods raise BailoException on API errors. These exceptions include the HTTP status code, error message, and full error context from the backend (e.g. per-field validation errors for model card or datacard updates). See the bailo.core.exceptions module documentation for details and usage examples.

class bailo.helper.access_request.AccessRequest(client, model_id, schema_id, metadata, access_request_id, created_by, deleted=False)[source]

Bases: object

Represent an access request within Bailo.

Parameters:
  • client (Client) – Bailo Client instance used for requests.

  • model_id (str) – Unique model ID.

  • schema_id (str) – ID of the schema used for the request.

  • metadata (Any) – Access request metadata.

  • access_request_id (str) – Unique ID for this access request.

  • created_by (str) – Username or ID of the request creator.

  • deleted (bool) – Whether the access request has been deleted, defaults to False.

classmethod from_id(client, model_id, access_request_id)[source]

Return an existing access request from Bailo given its unique ID.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A unique model ID within Bailo

  • access_request_id (str) – A unique ID for an access request

Returns:

AccessRequest object

Return type:

AccessRequest

classmethod create(client, model_id, metadata, schema_id=MinimalSchema.ACCESS_REQUEST)[source]

Make an access request for the model.

Posts an access request to Bailo to be reviewed

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A unique model ID within Bailo

  • metadata (Any) – Access request metadata.

  • schema_id (str) – A unique schema ID, defaults to minimal-access-request-general-v10

Returns:

AccessRequest object

Return type:

AccessRequest

delete()[source]

Delete the access request on Bailo.

Returns:

True if the access request was successfully deleted.

Return type:

bool

update()[source]

Update the access requests’s metadata on Bailo.

class bailo.helper.datacard.Datacard(client, datacard_id, name, description, organisation=None, state=None, tags=None, collaborators=None, visibility=None)[source]

Bases: Entry

Represent a datacard within Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • datacard_id (str) – A unique ID for the datacard

  • name (str) – Name of datacard

  • description (str) – Description of datacard

  • organisation (str | None) – Organisation responsible for the datacard, defaults to None

  • state (str | None) – Development readiness of the datacard, defaults to None

  • tags (list[str] | None) – Tags to assign to the datacard, defaults to None

  • collaborators (list[CollaboratorEntry] | None) – List of CollaboratorEntry to define who the datacard’s collaborators (a.k.a. model access) are, defaults to None

  • visibility (ModelVisibility | None) – Visibility of datacard, using ModelVisibility enum (e.g Public or Private), defaults to None

entry_kind: ClassVar[EntryKind] = 'data-card'

The entry kind represented by this subclass.

classmethod from_id(client, datacard_id)[source]

Return an existing datacard from Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • datacard_id (str) – A unique datacard ID

Returns:

A datacard object

Return type:

Datacard

update_data_card(data_card=None)[source]

Upload and retrieve any changes to the datacard on Bailo.

Parameters:

data_card (dict[str, Any] | None) – Datacard dictionary, defaults to None

Return type:

None

Note

If a datacard is not provided, the current datacard attribute value is used

property data_card: dict[str, Any] | None

Get the datacard metadata.

Returns:

Datacard as a dictionary.

classmethod _create_payload_extras(**kwargs)

Return additional arguments for the create request.

Parameters:

kwargs (Any) – Subclass-specific arguments passed to create().

Returns:

Dictionary of additional arguments for client.post_model.

Return type:

dict[str, Any]

classmethod _from_id(client, entry_id)

Return an existing entry from Bailo.

Subclasses expose this as from_id with their own ID parameter name.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • entry_id (str) – A unique entry ID

Returns:

An entry object

Return type:

EntryT

classmethod _id_kwarg(entry_id)

Return the ID as the keyword argument this subclass’ constructor expects.

Parameters:

entry_id (str) – A unique entry ID.

Returns:

Dictionary mapping the subclass ID parameter name to the given ID.

Return type:

dict[str, str]

classmethod _init_kwargs_from_response(res)

Return additional constructor arguments derived from an API response.

Parameters:

res (dict[str, Any]) – Response dictionary containing entry information.

Returns:

Dictionary of additional constructor arguments.

Return type:

dict[str, Any]

_unpack(res)

Update entry attributes from API response.

Parameters:

res – Response dictionary containing entry information.

_unpack_card(res)

Private method. Unpack card metadata, version, and schema ID from API response.

Parameters:

res – Card-related dictionary from the API response.

_update_card(card=None)

Update the card metadata for this entry on the Bailo server.

Parameters:

card (dict[str, Any] | None) – Metadata dictionary to update, defaults to None to use existing card.

Return type:

None

property card: dict[str, Any] | None

Get the metadata of the card.

Returns:

Card metadata.

card_from_schema(schema_id=None)

Create a card using a schema on Bailo.

Parameters:

schema_id (str | None) – A unique schema ID, defaults to None. If None, either minimal-general-v10 or minimal-data-card-v10 is used

Return type:

None

card_from_template(template_id)

Create a card using a template.

Parameters:

template_id (str) – Previous model’s unique ID to be used as template

Return type:

None

property card_schema: str | None

Get the schema ID of the card.

Returns:

Card schema ID.

property card_version: int | None

Get the version of the card.

Returns:

Card version.

classmethod create(client, name, description, organisation=None, state=None, tags=None, collaborators=None, visibility=None, **extra)

Build an entry from Bailo and upload it.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • name (str) – Name of the entry

  • description (str) – Description of the entry

  • organisation (str | None) – Organisation responsible for the entry, defaults to None

  • state (str | None) – Development readiness of the entry, defaults to None

  • tags (list[str] | None) – Tags to assign to the entry, defaults to None

  • collaborators (list[CollaboratorEntry] | None) – List of CollaboratorEntry to define who the entry’s collaborators (a.k.a. entry access) are, defaults to None

  • visibility (ModelVisibility | None) – Visibility of entry, using ModelVisibility enum (e.g Public or Private), defaults to None

  • extra (Any) – Subclass-specific arguments (e.g. sourceModelId)

Raises:

BailoException – If an argument not accepted by this entry kind is given

Returns:

Entry object

Return type:

EntryT

property data_card_version: int | None

Get the version of the datacard.

Returns:

Datacard version.

property datacard_id

Alias for Entry.id, kept for backwards compatibility.

delete()

Delete the entry from Bailo.

Return type:

Any

get_card_latest()

Get the latest card from Bailo.

Return type:

None

get_card_revision(version)

Get a specific entry card revision from Bailo.

Parameters:

version (str) – Entry card version

Return type:

None

get_roles()

Get all roles for the entry.

Returns:

List of roles

Return type:

list[dict[str, Any]]

classmethod search(client, task=None, libraries=None, filters=None, search='', organisations=None, states=None, allow_templating=None, schema_id=None, admin_access=None, peers=None, title_only=None)

Return a list of entry objects from Bailo, based on search parameters.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • task (str | None) – Entry task (e.g. image classification), defaults to None

  • libraries (list[str] | None) – Entry library (e.g. TensorFlow), defaults to None

  • filters (list[str] | None) – List of collaborator role filters. Special value “mine” restricts results to entries where the current user is a collaborator. Otherwise, values are treated as collaborator roles, defaults to None

  • search (str) – Free-text search string. Always performs a partial, case-insensitive match against the entry name. If title_only is False, a full-text search across entry content is also performed, defaults to “”

  • organisations (list[str] | None) – List of organisation identifiers to restrict results, defaults to None

  • states (list[str] | None) – List of entry lifecycle states to restrict results, defaults to None

  • allow_templating (bool | None) – If True, restricts results to entries with templating enabled, defaults to None

  • schema_id (str | None) – Schema ID to restrict results to entries using that schema, defaults to None

  • admin_access (bool | None) – If True, returns entries requiring admin access. The caller must have the Admin role or the request will be rejected by the backend, defaults to None

  • peers (list[str] | None) – List of peer identifiers to include remote search results from, defaults to None

  • title_only (bool | None) – If True, limits searching to entry titles only and disables full-text search, defaults to None

Returns:

List of entry objects

Return type:

list[EntryT]

update()

Upload and retrieve any changes to the entry summary on Bailo.

Return type:

None

settings: dict[str, Any] | None
property data_card_schema: str | None

Get the schema ID associated with the datacard.

Returns:

Schema ID of the datacard.

The Entry base class that every entry kind derives from lives in bailo.core.entry. It is re-exported from bailo.helper.entry for convenience, and its members are listed again on each subclass below.

class bailo.helper.entry.ReleaseMixin[source]

Bases: object

Release and image behaviour shared by the entry kinds that support releases.

Mixed into Entry subclasses, which provide client and id.

get_releases()[source]

Get all releases for the entry.

Returns:

List of Release objects

Return type:

list[Release]

get_release(version)[source]

Call the Release.from_version method to return an existing release from Bailo.

Parameters:

version (Version | str) – A semantic version for the release

Returns:

Release object

Return type:

Release

get_latest_release()[source]

Get the latest release for the entry from Bailo.

Returns:

Release object

Return type:

Release

get_images()[source]

Get all model image references for the entry.

Returns:

List of images

Return type:

list[str]

get_image()[source]

Get a model image reference.

Raises:

NotImplementedError – Not implemented error.

class bailo.helper.mirroredModel.MirroredModel(client, model_id, name, description, sourceModelId, organisation=None, state=None, tags=None, collaborators=None, visibility=None)[source]

Bases: ReleaseMixin, Entry

Represent a mirrored model within Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A unique ID for the mirrored model

  • name (str) – Name of mirrored model

  • description (str) – Description of mirrored model

  • sourceModelId (str) – Used for linking a mirrored model to its source model

  • organisation (str | None) – Organisation responsible for the mirrored model, defaults to None

  • state (str | None) – Development readiness of the mirrored model, defaults to None

  • tags (list[str] | None) – Tags to assign to the mirrored model, defaults to None

  • collaborators (list[CollaboratorEntry] | None) – List of CollaboratorEntry to define who the mirrored model’s collaborators (a.k.a. mirrored model access) are, defaults to None

  • visibility (ModelVisibility | None) – Visibility of the mirrored model, using ModelVisibility enum (e.g Public or Private), defaults to None

entry_kind: ClassVar[EntryKind] = 'mirrored-model'

The entry kind represented by this subclass.

classmethod create(client, name, description, sourceModelId, organisation=None, state=None, tags=None, collaborators=None, visibility=None, **extra)[source]

Build a mirrored model from Bailo and upload it.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • name (str) – Name of mirrored model

  • description (str) – Description of mirrored model

  • sourceModelId (str) – Used for linking a mirrored model to its source model

  • organisation (str | None) – Organisation responsible for the mirrored model, defaults to None

  • state (str | None) – Development readiness of the mirrored model, defaults to None

  • tags (list[str] | None) – Tags to assign to the mirrored model, defaults to None

  • collaborators (list[CollaboratorEntry] | None) – List of CollaboratorEntry to define who the mirrored model’s collaborators (a.k.a. model access) are, defaults to None

  • visibility (ModelVisibility | None) – Visibility of the mirrored model, using ModelVisibility enum (e.g Public or Private), defaults to None

  • extra (Any) – Rejected by Entry.create(), so that an unsupported argument raises the same BailoException here as it does for other entry kinds

Raises:

BailoException – If an argument not accepted by this entry kind is given

Returns:

MirroredModel object

Return type:

MirroredModel

classmethod from_id(client, model_id)[source]

Return an existing mirrored model from Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A unique mirrored model ID

Returns:

A mirrored model object

Return type:

MirroredModel

classmethod _create_payload_extras(**kwargs)[source]

Return the mirror-specific arguments for the create request.

Parameters:

kwargs (Any) – Subclass-specific arguments passed to create().

Returns:

Dictionary containing the source model ID.

Return type:

dict[str, Any]

classmethod _init_kwargs_from_response(res)[source]

Extract the source model ID from an API response.

Parameters:

res (dict[str, Any]) – Response dictionary containing model information.

Raises:

BailoException – If the response has no mirror source model ID.

Returns:

Dictionary containing the source model ID.

Return type:

dict[str, Any]

update()[source]

Upload and retrieve any changes to the mirrored model summary on Bailo.

Merges the sourceModelId into settings when it has changed, then delegates to the base update.

Return type:

None

_unpack(res)[source]

Update mirrored model attributes from API response.

Parameters:

res – Response dictionary containing model information.

update_model_card(model_card=None)[source]

Upload and retrieve any changes to the editable mirrored model card on Bailo.

Parameters:

model_card (dict[str, Any] | None) – Model card dictionary, defaults to None

Return type:

None

Note

If a model card is not provided, the current additional information value is used

_update_card(card=None)[source]

Update the editable additional information for this mirrored model on the Bailo server.

The card synced from the source model is read only, so the default falls back to the additional information rather than Entry._card.

Parameters:

card (dict[str, Any] | None) – Metadata dictionary to update, defaults to None to use the additional information.

Return type:

None

get_card_latest()[source]

Get the latest card from Bailo.

Return type:

None

_unpack_card(res, mirrored=False)[source]

Unpack a card from an API response into the mirrored or additional information slot.

Parameters:
  • res – Card-related dictionary from the API response.

  • mirrored – True for the card synced from the source model, False for the editable one.

Return type:

None

property model_card: dict[str, Any]

Get the data of the model card.

Returns:

Model card data.

property model_card_version: dict[str, int | None]

Get the version of the mirrored model card.

Returns:

Model card version.

property model_card_schema: str | None

Get the schema of the mirrored model card.

Returns:

Model card schema.

classmethod _from_id(client, entry_id)

Return an existing entry from Bailo.

Subclasses expose this as from_id with their own ID parameter name.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • entry_id (str) – A unique entry ID

Returns:

An entry object

Return type:

EntryT

classmethod _id_kwarg(entry_id)

Return the ID as the keyword argument this subclass’ constructor expects.

Parameters:

entry_id (str) – A unique entry ID.

Returns:

Dictionary mapping the subclass ID parameter name to the given ID.

Return type:

dict[str, str]

property card: dict[str, Any] | None

Get the metadata of the card.

Returns:

Card metadata.

card_from_schema(schema_id=None)

Create a card using a schema on Bailo.

Parameters:

schema_id (str | None) – A unique schema ID, defaults to None. If None, either minimal-general-v10 or minimal-data-card-v10 is used

Return type:

None

card_from_template(template_id)

Create a card using a template.

Parameters:

template_id (str) – Previous model’s unique ID to be used as template

Return type:

None

property card_schema: str | None

Get the schema ID of the card.

Returns:

Card schema ID.

property card_version: int | None

Get the version of the card.

Returns:

Card version.

delete()

Delete the entry from Bailo.

Return type:

Any

get_card_revision(version)

Get a specific entry card revision from Bailo.

Parameters:

version (str) – Entry card version

Return type:

None

get_image()

Get a model image reference.

Raises:

NotImplementedError – Not implemented error.

get_images()

Get all model image references for the entry.

Returns:

List of images

Return type:

list[str]

get_latest_release()

Get the latest release for the entry from Bailo.

Returns:

Release object

Return type:

Release

get_release(version)

Call the Release.from_version method to return an existing release from Bailo.

Parameters:

version (Version | str) – A semantic version for the release

Returns:

Release object

Return type:

Release

get_releases()

Get all releases for the entry.

Returns:

List of Release objects

Return type:

list[Release]

get_roles()

Get all roles for the entry.

Returns:

List of roles

Return type:

list[dict[str, Any]]

property model_id

Alias for Entry.id, kept for backwards compatibility.

classmethod search(client, task=None, libraries=None, filters=None, search='', organisations=None, states=None, allow_templating=None, schema_id=None, admin_access=None, peers=None, title_only=None)

Return a list of entry objects from Bailo, based on search parameters.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • task (str | None) – Entry task (e.g. image classification), defaults to None

  • libraries (list[str] | None) – Entry library (e.g. TensorFlow), defaults to None

  • filters (list[str] | None) – List of collaborator role filters. Special value “mine” restricts results to entries where the current user is a collaborator. Otherwise, values are treated as collaborator roles, defaults to None

  • search (str) – Free-text search string. Always performs a partial, case-insensitive match against the entry name. If title_only is False, a full-text search across entry content is also performed, defaults to “”

  • organisations (list[str] | None) – List of organisation identifiers to restrict results, defaults to None

  • states (list[str] | None) – List of entry lifecycle states to restrict results, defaults to None

  • allow_templating (bool | None) – If True, restricts results to entries with templating enabled, defaults to None

  • schema_id (str | None) – Schema ID to restrict results to entries using that schema, defaults to None

  • admin_access (bool | None) – If True, returns entries requiring admin access. The caller must have the Admin role or the request will be rejected by the backend, defaults to None

  • peers (list[str] | None) – List of peer identifiers to include remote search results from, defaults to None

  • title_only (bool | None) – If True, limits searching to entry titles only and disables full-text search, defaults to None

Returns:

List of entry objects

Return type:

list[EntryT]

settings
class bailo.helper.model.Model(client, model_id, name, description, organisation=None, state=None, tags=None, collaborators=None, visibility=None)[source]

Bases: ReleaseMixin, Entry

Represent a model within Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A unique ID for the model

  • name (str) – Name of model

  • description (str) – Description of model

  • organisation (str | None) – Organisation responsible for the model, defaults to None

  • state (str | None) – Development readiness of the model, defaults to None

  • tags (list[str] | None) – Tags to assign to the model, defaults to None

  • collaborators (list[CollaboratorEntry] | None) – List of CollaboratorEntry to define who the model’s collaborators (a.k.a. model access) are, defaults to None

  • visibility (ModelVisibility | None) – Visibility of model, using ModelVisibility enum (e.g Public or Private), defaults to None

entry_kind: ClassVar[EntryKind] = 'model'

The entry kind represented by this subclass.

classmethod from_id(client, model_id)[source]

Return an existing model from Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A unique model ID

Returns:

A model object

Return type:

Model

classmethod from_mlflow(client, mlflow_uri, name, schema_id=MinimalSchema.MODEL, version=None, files=True, visibility=None, organisation=None, state=None, tags=None, collaborators=None)[source]

Import an MLFlow Model into Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • mlflow_uri (str) – MLFlow server URI

  • name (str) – Name of model (on MLFlow). Same name will be used on Bailo

  • schema_id (str) – A unique schema ID, only required when files is True, defaults to minimal-general-v10

  • version (str | None) – Specific MLFlow model version to import, defaults to None

  • files (bool) – Import files?, defaults to True

  • visibility (ModelVisibility | None) – Visibility of model on Bailo, using ModelVisibility enum (e.g Public or Private), defaults to None

  • organisation (str | None) – Organisation responsible for the model, defaults to None

  • state (str | None) – Development readiness of the model, defaults to None

  • tags (list[str] | None) – Tags to assign to the model, defaults to None

  • collaborators (list[CollaboratorEntry] | None) – List of CollaboratorEntry to define who the model’s collaborators (a.k.a. model access) are, defaults to None

Returns:

A model object

Return type:

Model

update_model_card(model_card=None)[source]

Upload and retrieve any changes to the model card on Bailo.

Parameters:

model_card (dict[str, Any] | None) – Model card dictionary, defaults to None

Return type:

None

Note

If a model card is not provided, the current model card attribute value is used

create_experiment()[source]

Create an experiment locally

Returns:

An experiment object

Return type:

Experiment

create_release(version, notes, files=None, images=None, minor=False, draft=True)[source]

Call the Release.create method to build a release from Bailo and upload it.

Parameters:
  • version (Version | str) – A semantic version for the release

  • notes (str) – Notes on release

  • files (list[str] | None) – A list of files for release, defaults to None

  • images (list[str] | None) – A list of images for release, defaults to None

  • minor (bool) – Is a minor release?, defaults to False

  • draft (bool) – Is a draft release?, defaults to True

Returns:

Release object

Return type:

Release

property model_card: dict[str, Any] | None

Get the data of the model card.

Returns:

Model card data.

property model_card_version: int | None

Get the version of the model card.

Returns:

Model card version.

property model_card_schema: str | None

Get the schema of the model card.

Returns:

Model card schema.

classmethod _create_payload_extras(**kwargs)

Return additional arguments for the create request.

Parameters:

kwargs (Any) – Subclass-specific arguments passed to create().

Returns:

Dictionary of additional arguments for client.post_model.

Return type:

dict[str, Any]

classmethod _from_id(client, entry_id)

Return an existing entry from Bailo.

Subclasses expose this as from_id with their own ID parameter name.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • entry_id (str) – A unique entry ID

Returns:

An entry object

Return type:

EntryT

classmethod _id_kwarg(entry_id)

Return the ID as the keyword argument this subclass’ constructor expects.

Parameters:

entry_id (str) – A unique entry ID.

Returns:

Dictionary mapping the subclass ID parameter name to the given ID.

Return type:

dict[str, str]

classmethod _init_kwargs_from_response(res)

Return additional constructor arguments derived from an API response.

Parameters:

res (dict[str, Any]) – Response dictionary containing entry information.

Returns:

Dictionary of additional constructor arguments.

Return type:

dict[str, Any]

_unpack(res)

Update entry attributes from API response.

Parameters:

res – Response dictionary containing entry information.

_unpack_card(res)

Private method. Unpack card metadata, version, and schema ID from API response.

Parameters:

res – Card-related dictionary from the API response.

_update_card(card=None)

Update the card metadata for this entry on the Bailo server.

Parameters:

card (dict[str, Any] | None) – Metadata dictionary to update, defaults to None to use existing card.

Return type:

None

property card: dict[str, Any] | None

Get the metadata of the card.

Returns:

Card metadata.

card_from_schema(schema_id=None)

Create a card using a schema on Bailo.

Parameters:

schema_id (str | None) – A unique schema ID, defaults to None. If None, either minimal-general-v10 or minimal-data-card-v10 is used

Return type:

None

card_from_template(template_id)

Create a card using a template.

Parameters:

template_id (str) – Previous model’s unique ID to be used as template

Return type:

None

property card_schema: str | None

Get the schema ID of the card.

Returns:

Card schema ID.

property card_version: int | None

Get the version of the card.

Returns:

Card version.

classmethod create(client, name, description, organisation=None, state=None, tags=None, collaborators=None, visibility=None, **extra)

Build an entry from Bailo and upload it.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • name (str) – Name of the entry

  • description (str) – Description of the entry

  • organisation (str | None) – Organisation responsible for the entry, defaults to None

  • state (str | None) – Development readiness of the entry, defaults to None

  • tags (list[str] | None) – Tags to assign to the entry, defaults to None

  • collaborators (list[CollaboratorEntry] | None) – List of CollaboratorEntry to define who the entry’s collaborators (a.k.a. entry access) are, defaults to None

  • visibility (ModelVisibility | None) – Visibility of entry, using ModelVisibility enum (e.g Public or Private), defaults to None

  • extra (Any) – Subclass-specific arguments (e.g. sourceModelId)

Raises:

BailoException – If an argument not accepted by this entry kind is given

Returns:

Entry object

Return type:

EntryT

delete()

Delete the entry from Bailo.

Return type:

Any

get_card_latest()

Get the latest card from Bailo.

Return type:

None

get_card_revision(version)

Get a specific entry card revision from Bailo.

Parameters:

version (str) – Entry card version

Return type:

None

get_image()

Get a model image reference.

Raises:

NotImplementedError – Not implemented error.

get_images()

Get all model image references for the entry.

Returns:

List of images

Return type:

list[str]

get_latest_release()

Get the latest release for the entry from Bailo.

Returns:

Release object

Return type:

Release

get_release(version)

Call the Release.from_version method to return an existing release from Bailo.

Parameters:

version (Version | str) – A semantic version for the release

Returns:

Release object

Return type:

Release

get_releases()

Get all releases for the entry.

Returns:

List of Release objects

Return type:

list[Release]

get_roles()

Get all roles for the entry.

Returns:

List of roles

Return type:

list[dict[str, Any]]

property model_id

Alias for Entry.id, kept for backwards compatibility.

classmethod search(client, task=None, libraries=None, filters=None, search='', organisations=None, states=None, allow_templating=None, schema_id=None, admin_access=None, peers=None, title_only=None)

Return a list of entry objects from Bailo, based on search parameters.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • task (str | None) – Entry task (e.g. image classification), defaults to None

  • libraries (list[str] | None) – Entry library (e.g. TensorFlow), defaults to None

  • filters (list[str] | None) – List of collaborator role filters. Special value “mine” restricts results to entries where the current user is a collaborator. Otherwise, values are treated as collaborator roles, defaults to None

  • search (str) – Free-text search string. Always performs a partial, case-insensitive match against the entry name. If title_only is False, a full-text search across entry content is also performed, defaults to “”

  • organisations (list[str] | None) – List of organisation identifiers to restrict results, defaults to None

  • states (list[str] | None) – List of entry lifecycle states to restrict results, defaults to None

  • allow_templating (bool | None) – If True, restricts results to entries with templating enabled, defaults to None

  • schema_id (str | None) – Schema ID to restrict results to entries using that schema, defaults to None

  • admin_access (bool | None) – If True, returns entries requiring admin access. The caller must have the Admin role or the request will be rejected by the backend, defaults to None

  • peers (list[str] | None) – List of peer identifiers to include remote search results from, defaults to None

  • title_only (bool | None) – If True, limits searching to entry titles only and disables full-text search, defaults to None

Returns:

List of entry objects

Return type:

list[EntryT]

update()

Upload and retrieve any changes to the entry summary on Bailo.

Return type:

None

client
id
settings
class bailo.helper.model.Experiment(model)[source]

Bases: object

Represent an experiment locally.

Parameters:
  • model (Model) – A Bailo model object which the experiment is being run on

  • raw – Raw information about the experiment runs

experiment = model.create_experiment()
for x in range(5):
    experiment.start_run()
    experiment.log_params({"lr": 0.01})
    ### INSERT MODEL TRAINING HERE ###
    experiment.log_metrics("accuracy": 0.86)
    experiment.log_artifacts(["weights.pth"])

experiment.publish(mc_loc="performance.performanceMetrics", run_id=1)
classmethod create(model)[source]

Create an experiment locally.

Parameters:

model (Model) – A Bailo model object which the experiment is being run on

Returns:

Experiment object

Return type:

Experiment

start_run(is_mlflow=False)[source]

Starts a new experiment run.

Parameters:

is_mlflow (bool) – Marks a run as MLFlow

log_params(params)[source]

Logs parameters to the current run.

Parameters:

params (dict[str, Any]) – Dictionary of parameters to be logged

log_metrics(metrics)[source]

Logs metrics to the current run.

Parameters:

metrics (dict[str, Any]) – Dictionary of metrics to be logged

log_artifacts(artifacts)[source]

Logs artifacts to the current run.

Parameters:

artifacts (list) – A list of artifact paths to be logged

log_dataset(dataset)[source]

Logs a dataset to the current run.

Parameters:

dataset (str) – Arbitrary title of dataset

from_mlflow(tracking_uri, experiment_id)[source]

Imports information from an MLFlow Tracking experiment.

Parameters:
  • tracking_uri (str) – MLFlow Tracking server URI

  • experiment_id (str) – MLFlow Tracking experiment ID

Raises:

ImportError – Import error if MLFlow not installed

publish(mc_loc, semver='0.1.0', notes='', run_id=None, select_by=None)[source]

Publishes a given experiments results to the model card.

Parameters:
  • mc_loc (str) – Location of metrics in the model card (e.g. performance.performanceMetrics)

  • semver (str) – Semantic version of release to create (if artifacts present), defaults to 0.1.0 or next

  • notes (str) – Notes for release, defaults to “”

  • run_id (str | None) – Local experiment run ID to be selected, defaults to None

  • select_by (str | None) – String describing experiment to be selected (e.g. “accuracy MIN|MAX”), defaults to None

Note

mc_loc is dependent on the model card schema being used

Warning

User must specify either run_id or select_by, otherwise the code will error

class bailo.helper.release.Release(client, model_id, version, model_card_version, notes='', files=None, images=None, minor=False, draft=True)[source]

Bases: object

Parameters:
  • client (Client)

  • model_id (str)

  • version (Version | str)

  • model_card_version (int)

  • notes (str)

  • files (list[str] | None)

  • images (list[str] | None)

  • minor (bool)

  • draft (bool)

__init__(client, model_id, version, model_card_version, notes='', files=None, images=None, minor=False, draft=True)[source]

Represent a release within Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A unique model ID

  • version (Version | str) – A semantic version for the release

  • model_card_version (int) – Version of the model card

  • notes (str) – Notes on release

  • files (list[str] | None) – (optional) A list of files for release

  • images (list[str] | None) – (optional) A list of images for release

  • minor (bool) – Is a minor release?

  • draft (bool) – Is a draft release?

Return type:

None

Note

Currently files and images are stored as string references

classmethod create(client, model_id, version, notes, model_card_version, files=None, images=None, minor=False, draft=True)[source]

Build a release from Bailo and uploads it.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A Unique Model ID

  • version (Version | str) – A semantic version of a model release

  • notes (str) – Notes on release

  • model_card_version (int) – Model card version

  • files (list[str] | None) – Files for release, defaults to None

  • images (list[str] | None) – Images for release, defaults to None

  • minor (bool) – Signifies a minor release, defaults to False

  • draft (bool) – Signifies a draft release, defaults to False

Returns:

Release object

Return type:

Release

classmethod from_version(client, model_id, version)[source]

Return an existing release from Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A Unique Model ID

  • version (Version | str) – A semantic version of a model release

Returns:

Release object

Return type:

Release

classmethod _from_json(client, model_id, res, version=None)[source]

Build a release from a release object in an API response.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • model_id (str) – A Unique Model ID

  • res (dict[str, Any]) – A single release object from an API response

  • version (Version | str | None) – Version to use in place of the response’s semver, defaults to None

Returns:

Release object

Return type:

Release

download(filename, write=True, path=None)[source]

Returns a response object given the file name and optionally writes file to disk.

Parameters:
  • filename (str) – The name of the file to retrieve

  • write (bool) – Bool to determine if writing file to disk, defaults to True

  • path (str | None) – Local path to write file to (if write set to True)

Returns:

A JSON response object

Return type:

Any

download_all(path='/home/runner/work/Bailo/Bailo/backend/docs', include=None, exclude=None)[source]

Writes all files in a release to disk at the given path, applying inclusion/exclusion filters.

Parameters:
  • path (str) – Local directory to output files.

  • include (list | str | None) – List of glob patterns (str) or single string to include, defaults to None

  • exclude (list | str | None) – List of glob patterns (str) or single string to exclude, defaults to None

Raises:

BailoException – If the release has no files assigned.

Note

Fnmatch statements support Unix shell-style wildcards.

upload(path, data=None)[source]

Upload a file to the release.

Parameters:
  • path (str) – The path, or name of file or directory to be uploaded

  • data (BytesIO | None) – A BytesIO object if not loading from disk, defaults to None

Returns:

The unique file ID of the file uploaded

Return type:

str

Note

If path provided is a directory, it will be uploaded as a zip

update()[source]

Update the any changes to this release on Bailo.

Returns:

JSON Response object

Return type:

Any

delete()[source]

Delete a release from Bailo.

Returns:

JSON Response object

Return type:

Any

property version
class bailo.helper.schema.Schema(client, schema_id, name, description, kind, json_schema, review_roles)[source]

Bases: object

Represent a schema within Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • schema_id (str) – A unique schema ID

  • name (str) – Name of schema

  • description (str) – Description of the schema

  • kind (SchemaKind) – Kind of schema, using SchemaKind enum (e.g Model or AccessRequest)

  • json_schema (dict[str, Any]) – Schema JSON

  • review_roles (list[str]) – List made up of the “shortName” property from a Review Role object

classmethod create(client, schema_id, name, description, kind, json_schema, review_roles)[source]

Build a schema from Bailo and uploads it.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • schema_id (str) – A unique schema ID

  • name (str) – Name of schema

  • description (str) – Description of schema

  • kind (SchemaKind) – Kind of schema, using SchemaKind enum (e.g Model or AccessRequest)

  • json_schema (dict[str, Any]) – Schema JSON

  • review_roles (list[str]) – List made up of the “shortName” property from a Review Role object

Returns:

Schema object

Return type:

Schema

classmethod from_id(client, schema_id)[source]

Return an existing schema from Bailo.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • schema_id (str) – A unique schema ID

Returns:

Schema object

Return type:

Schema

static get_all_schema_ids(client, kind=None)[source]

Return all schema ids for a given type.

Parameters:
  • client (Client) – A client object used to interact with Bailo

  • kind (SchemaKind | None) – Enum to define schema kind (e.g. Model or AccessRequest), defaults to None

Returns:

List of schema IDs

Return type:

list[str]