Organization

class deepint.core.Organization(organization_id: str, credentials: Credentials, workspaces: List[Workspace], account: Dict[Any, Any])

A Deep Intelligence Organization.

Note: This class should not be instanced directly, and it’s recommended to use the deepint.core.organization.Organization.build

method.

organization_id

the id of the organization.

workspaces

deepint.core.organization.OrganizationWorkspaces to operate with organization’s workspaces.

account

dict containing information about the providen token, like permissions and associated account details like id or name.

credentials

credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the task. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

endpoint

objet to call a custom endpoint of Deep Intelligence.

classmethod build(organization_id: Optional[str] = None, credentials: Optional[Credentials] = None) Organization

Builds an organization.

Note: when organization is created, the organization’s information and account are retrieved from API.

Parameters:
  • organization_id – the id of the organization.

  • credentials – credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the organization. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

Returns:

the organization build with the given parameters and credentials.

clean()

Deletes all workspaces in organization.

classmethod from_url(url: str, organization_id: Optional[str] = None, credentials: Optional[Credentials] = None) Workspace

Builds an organization from it’s API or web associated URL.

The url must contain the workspace’s id as in the following examples:

Example

Note: when organization is created, the organization’s information and list of it’s associated objects (workspaces) are loaded.

Also it is remmarkable that if the API URL is providen, the organization_id must be provided in the optional parameter, otherwise this ID won’t be found on the URL and the Organization will not be created, raising a value error.

Parameters:
  • url – the workspace’s API or web associated URL.

  • organization_id – the id of the organziation. Must be providen if the API URL is used.

  • credentials – credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the workspace. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

Returns:

the workspace build with the URL and credentials.

load()

Loads the organization’s information and account.

If the organization’s or account’s information is already loaded, is replace by the new one after retrieval.

to_dict() Dict[str, Any]

Builds a dictionary containing the information stored in current object.

Returns:

dictionary contining the information stored in the current object.

class deepint.core.organization.OrganizationWorkspaces(organization: Organization, workspaces: List[Workspace])

Operates over the worksapces of a concrete organization.

Note: This class should not be instanced, and only be used within an deepint.core.organization.Organization

organization

the organization with which to operate with its worksapces

create(name: str, description: str) Workspace

Creates a workspace in current organization.

Before creation, the workspace is loaded and stored locally in the internal list of workspaces in the current instance.

Parameters:
  • name – new workspace’s name.

  • descrpition – new workspace’s description.

Returns:

the created workspace

create_if_not_exists(name: str) Workspace

Creates a workspace in current organization if not exists, else retrieves the given worksapce.

The source is created with the deepint.core.organization.OrganizationWorkspaces.create, so it’s reccomended to read the documentation of that method to learn more about the possible artguments of creation. Before creation, the workspace is loaded and stored locally in the internal list of workspaces in the current instance.

Parameters:

name – new workspace’s name.

Returns:

the created workspace if not exists, else the retrieved workspace

fetch(workspace_id: Optional[str] = None, name: Optional[str] = None, force_reload: bool = False) Optional[Workspace]

Search for a workspace in the organization.

The first time is invoked, buidls a generator to retrieve workspaces directly from deepint.net API. However, if there is stored workspaces and the force_reload option is not specified, only iterates in local workspaces. In other case, it request the workspaces to deepint.net API and iterates over it.

Note: if no name or id is provided, the returned value is None.

Parameters:
Returns:

retrieved workspace if found, and in other case None.

fetch_all(force_reload: bool = False) Generator[Workspace, None, None]

Retrieves all organization’s workspaces.

The first time is invoked, buidls a generator to retrieve workspaces directly from deepint.net API. However, if there is stored workspaces and the force_reload option is not specified, only iterates in local workspaces. In other case, it request the workspaces to deepint.net API and iterates over it.

Parameters:

force_reload – if set to True, workspaces are reloaded before the search with the deepint.core.organization.OrganizationWorkspaces.load method.

Yields:

deepint.core.workspace.Workspace – The next workspace returned by deeepint.net API.

Returns:

the organization’s workspaces.

import_ws(name: str, description: str, file_path: str, wait_for_creation: bool = True) Workspace

Imports a workspace to ZIP into the selected path.

Parameters:
  • name – new workspace’s name.

  • description – new workspace’s description.

  • file_path – the path where the zip must be located. This parameter must contain the name of the file.

Returns:

The created workspace in the case of wait_for_creation is set to True, or a task that on resolve will contain the

workspace’s id.

load()

Loads a organization’s workspaces.

If the workspaces were already loaded, this ones are replace by the new ones after retrieval.