crux package

Submodules

crux.apis module

Module contains Crux object to interact with root APIs.

class crux.apis.Crux(api_key: Optional[str] = None, api_host: Optional[str] = None, proxies: Optional[MutableMapping[str, str]] = None, user_agent: Optional[str] = None, api_prefix: Optional[str] = None, only_use_crux_domains: Optional[bool] = None)

Bases: object

Crux APIs.

close()

Closes the Connection.

create_dataset(name: str, description: Optional[str] = None, tags: Optional[List[str]] = None) → crux.models.dataset.Dataset

Creates the Dataset.

Parameters
  • name (str) – Sets whether to sort or not.

  • description (str) – Folder for which resource should be listed. Defaults to None.

  • tags (list of str) – Sets the offset. Defaults to None.

Returns

Dataset object.

Return type

crux.models.Dataset

get_dataset(id: str) → crux.models.dataset.Dataset

Fetches the Dataset.

Parameters

id (str) – Dataset ID which is to be fetched.

Returns

Dataset object

Return type

crux.models.Dataset

get_job(job_id: str) → crux.models.job.Job

Fetches the Job.

Parameters

job_id (str) – Job ID which is to be fetched.

Returns

Job object.

Return type

crux.models.Job

get_resource(id: str) → Union[crux.models.file.File, crux.models.folder.Folder]

Fetches the Resource by ID.

Any supported resource can be fetched. The object returned will be an instance of the correct subclass, for example a crux.models.File instance will be returned for file resources.

Parameters

id (str) – Resource ID which is to be fetched.

Returns

Resource or its Child Object.

Return type

crux.models.Resource

list_datasets(owned: bool = True, subscribed: bool = True) → List[crux.models.dataset.Dataset]

Fetches a list of owned and/or subscribed Datasets.

Parameters
  • owned (bool) – Show datasets owned by the caller. Defaults to True.

  • subscribed (bool) – Show datasets the user has a subscription. Defaults to True.

Returns

List of Dataset objects.

Return type

list(crux.models.Dataset)

list_public_datasets() → List[crux.models.dataset.Dataset]

Fetches a list of public Datasets.

Returns

List of Dataset objects.

Return type

list (crux.models.Dataset)

set_datasets_provenance(provenance)

Sets the Dataset Provenance

Parameters

provenance (dict) – Provenance dictionary

Returns

Provenance response dictionary.

Return type

dict

Example

from crux import Crux

conn = Crux()

provenance = {
    "dataset_id":[
        {
            "workflow_id": "test_id",
            "pipeline_ids": ["test_id_1","test_id_2"],
            "cron_spec": "0 0 1 1 0"
            }
        ]
    }
response = conn.set_datasets_provenance(provenance=provenance)
whoami() → crux.models.identity.Identity

Returns the Identity of Current User.

Returns

Identity object.

Return type

crux.models.Identity

crux.exceptions module

Module contains the set of crux-python’s exceptions.

exception crux.exceptions.CruxAPIError(message: Dict[str, Union[str, int]])

Bases: Exception

Exception which should be raised when the API response expects an error.

exception crux.exceptions.CruxClientConnectionError(message: str)

Bases: crux.exceptions.CruxClientError

Exception should be raised when SDK expects any connection related errors.

exception crux.exceptions.CruxClientError(message: str)

Bases: Exception

Exception which should be raised when the client SDK expects an error.

exception crux.exceptions.CruxClientHTTPError(message: str, response: requests.models.Response)

Bases: crux.exceptions.CruxClientError

Exception should be raised when SDK expects any HTTP related errors.

exception crux.exceptions.CruxClientTimeout(message: str)

Bases: crux.exceptions.CruxClientError

Exception should be raised when SDK expects any timeout related errors.

exception crux.exceptions.CruxClientTooManyRedirects(message: str)

Bases: crux.exceptions.CruxClientError

Exception should be raised when SDK gets too many redirects.

exception crux.exceptions.CruxResourceNotFoundError(message: Dict[str, Union[str, int]])

Bases: crux.exceptions.CruxAPIError

Exception which should be raised when Crux Resource is not found.

Module contents

Module packages root level crux objects.

class crux.Crux(api_key: Optional[str] = None, api_host: Optional[str] = None, proxies: Optional[MutableMapping[str, str]] = None, user_agent: Optional[str] = None, api_prefix: Optional[str] = None, only_use_crux_domains: Optional[bool] = None)

Bases: object

Crux APIs.

close()

Closes the Connection.

create_dataset(name: str, description: Optional[str] = None, tags: Optional[List[str]] = None) → crux.models.dataset.Dataset

Creates the Dataset.

Parameters
  • name (str) – Sets whether to sort or not.

  • description (str) – Folder for which resource should be listed. Defaults to None.

  • tags (list of str) – Sets the offset. Defaults to None.

Returns

Dataset object.

Return type

crux.models.Dataset

get_dataset(id: str) → crux.models.dataset.Dataset

Fetches the Dataset.

Parameters

id (str) – Dataset ID which is to be fetched.

Returns

Dataset object

Return type

crux.models.Dataset

get_job(job_id: str) → crux.models.job.Job

Fetches the Job.

Parameters

job_id (str) – Job ID which is to be fetched.

Returns

Job object.

Return type

crux.models.Job

get_resource(id: str) → Union[crux.models.file.File, crux.models.folder.Folder]

Fetches the Resource by ID.

Any supported resource can be fetched. The object returned will be an instance of the correct subclass, for example a crux.models.File instance will be returned for file resources.

Parameters

id (str) – Resource ID which is to be fetched.

Returns

Resource or its Child Object.

Return type

crux.models.Resource

list_datasets(owned: bool = True, subscribed: bool = True) → List[crux.models.dataset.Dataset]

Fetches a list of owned and/or subscribed Datasets.

Parameters
  • owned (bool) – Show datasets owned by the caller. Defaults to True.

  • subscribed (bool) – Show datasets the user has a subscription. Defaults to True.

Returns

List of Dataset objects.

Return type

list(crux.models.Dataset)

list_public_datasets() → List[crux.models.dataset.Dataset]

Fetches a list of public Datasets.

Returns

List of Dataset objects.

Return type

list (crux.models.Dataset)

set_datasets_provenance(provenance)

Sets the Dataset Provenance

Parameters

provenance (dict) – Provenance dictionary

Returns

Provenance response dictionary.

Return type

dict

Example

from crux import Crux

conn = Crux()

provenance = {
    "dataset_id":[
        {
            "workflow_id": "test_id",
            "pipeline_ids": ["test_id_1","test_id_2"],
            "cron_spec": "0 0 1 1 0"
            }
        ]
    }
response = conn.set_datasets_provenance(provenance=provenance)
whoami() → crux.models.identity.Identity

Returns the Identity of Current User.

Returns

Identity object.

Return type

crux.models.Identity