MyTardis Client API

MyTardis Client provides various Python classes for interacting with MyTardis’s REST API.

mytardisclient.models.api

The api module contains model classes for MyTardis API v1’s endpoints. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

This following lists all of the supported endpoints: /api/v1/?format=json

API functionality available for a particular model can be retrieved with:
/api/v1/facility/schema/?format=json

The ‘schema’ request above requires authentication.

class mytardisclient.models.api.ApiEndpoint(model, endpoint_json)

Bases: object

Model class for MyTardis API v1’s endpoints. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static list(*arg, **kw)

Retrieve a list of API endpoints, encapsulated in an ApiEndpoints object.

The ApiEndpoints object encapsulates the entire JSON response from the /api/v1/ query.

Returns:A list of API endpoints, encapsulated in an ApiEndpoints object.
class mytardisclient.models.api.ApiEndpoints(json)

Bases: object

Dictionary of API endpoints (list_endpoint and schema) with model names as keys.

next()

Return the next item from the ApiEndpoints set. If there are no further items, raise the StopIteration exception.

class mytardisclient.models.api.ApiSchema(model, schema_json)

Bases: object

Model class for MyTardis API v1’s schemas. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static get(*arg, **kw)

Get a list of API-accessible functionality for a particular model.

Parameters:model – The name of an API-accessible model, e.g. ‘dataset_file’.
Returns:An ApiSchema object, which encapsulates the list of API-accessible functionality for a particular model.

mytardisclient.models.config

Model class for the configuration, usually stored in ~/.config/mytardisclient/mytardisclient.cfg

class mytardisclient.models.config.Config(path='/Users/wettenhj/.config/mytardisclient/mytardisclient.cfg')

Bases: object

Model class for the minimal MyTardis server configuration (MyTardis URL, username and API key), usually stored in ~/.config/mytardisclient/mytardisclient.cfg

apikey = None

The MyTardis API key, e.g. ‘644be179cc6773c30fc471bad61b50c90897146c’

cache_backend = None

Cache backend. Default: ‘dogpile.cache.dbm’. Set to ‘dogpile.cache.null’ to disable caching.

cache_expiry = None

Cache expiry time. Default: 30 seconds.

cache_path = None

Path for caching results of frequently used queries. Default: ~/.cache/mytardisclient/mytardisclient.cache

datasets_path
default_headers

Default headers to use for API queries (including API key authorization).

hostname
load(path=None)

Sets some default values for settings fields, then loads a config file.

Parameters:path – The path to the config file, usually ~/.config/mytardisclient/mytardisclient.cfg
logging_config_path = None

The logging config path. Default: ~/.config/mytardisclient/logging.cfg

path = None

The config file’s location. Default: ~/.config/mytardisclient/mytardisclient.cfg

save(path=None)

Saves the configuration to disk.

Parameters:path – The path to save to, usually ~/.config/mytardisclient/mytardisclient.cfg
url = None

The MyTardis URL, e.g. ‘http://mytardisdemo.erc.monash.edu.au

username = None

The MyTardis username, e.g. ‘demofacility”

validate()

Ensure that the config contains a non-empty username, API key and MyTardis URL.

mytardisclient.models.facility

Model class for MyTardis API v1’s FacilityResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

class mytardisclient.models.facility.Facility(facility_json)

Bases: object

Model class for MyTardis API v1’s FacilityResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static get(*arg, **kw)

Get facility with ID facility_id

Parameters:facility_id – The ID of a facility to retrieve.
Returns:A Facility record.
static list(*arg, **kw)

Retrieve a list of facilities.

Parameters:
  • limit – Maximum number of results to return.
  • offset – Skip this many records from the start of the result set.
  • order_by – Order by this field.
Returns:

A list of Facility records, encapsulated in a ResultSet object`.

mytardisclient.models.instrument

Model class for MyTardis API v1’s InstrumentResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

class mytardisclient.models.instrument.Instrument(instrument_json)

Bases: object

Model class for MyTardis API v1’s InstrumentResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static create(facility_id, name)

Create an instrument record.

Parameters:
  • facility_id – The ID of the facility to create the instrument in.
  • name – The name of the instrument.
Returns:

A new Instrument record.

static get(*arg, **kw)

Get instrument with ID instrument_id

Parameters:instrument_id – The ID of an instrument to retrieve.
Returns:An Instrument record.
static list(*arg, **kw)

Retrieve a list of instruments in a facility with ID facility_id.

Parameters:
  • facility_id – The ID of a facility to retrieve instruments from.
  • limit – Maximum number of results to return.
  • offset – Skip this many records from the start of the result set.
  • order_by – Order by this field.
Returns:

A list of Instrument records, encapsulated in a ResultSet object.

static update(instrument_id, name)

Update an instrument record.

Parameters:
  • instrument_id – The ID of the instrument record to update.
  • name – The new name of the instrument.
Returns:

An updated Instrument record.

mytardisclient.models.experiment

Model class for MyTardis API v1’s ExperimentResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

class mytardisclient.models.experiment.Experiment(experiment_json=None, include_metadata=True)

Bases: object

Model class for MyTardis API v1’s ExperimentResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static create(title, description='', institution=None, params_file_json=None)

Create an experiment record.

Parameters:
  • title – The title of the experiment.
  • description – The description of the experiment.
  • institution – The institution of the experiment.
  • params_file_json – Path to a JSON file with experiment parameters.
Returns:

A new Dataset record.

static get(*arg, **kw)

Get experiment with ID exp_id

Parameters:exp_id – The ID of an experiment to retrieve.
Returns:An Experiment record.
static list(*arg, **kw)

Retrieve a list of experiments.

Parameters:
  • filters – Filters, e.g. “title=Exp Title”
  • limit – Maximum number of results to return.
  • offset – Skip this many records from the start of the result set.
  • order_by – Order by this field.
Returns:

A list of Experiment records, encapsulated in a ResultSet object.

static update(experiment_id, title, description)

Update an experiment record.

class mytardisclient.models.experiment.ExperimentParameter(expparam_json)

Bases: object

Model class for MyTardis API v1’s ExperimentParameterResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static list(*arg, **kw)

List experiment parameter records in parameter set.

class mytardisclient.models.experiment.ExperimentParameterSet(expparamset_json)

Bases: object

Model class for MyTardis API v1’s ExperimentParameterSetResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static list(*arg, **kw)

List experiment parameter sets associated with experiment ID experiment_id.

Parameters:experiment_id – The ID of the experiment to retrieve parameter sets for.
Returns:A list of ExperimentParameterSet records, encapsulated in a ResultSet object`.

mytardisclient.models.dataset

Model class for MyTardis API v1’s DatasetResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

class mytardisclient.models.dataset.Dataset(dataset_json=None, include_metadata=True)

Bases: object

Model class for MyTardis API v1’s DatasetResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static create(experiment_id, description, instrument_id=None, params_file_json=None)

Create a dataset record.

Parameters:
  • experiment_id – The ID of the experiment to create the dataset in.
  • description – The description of the dataset.
  • instrument_id – The instrument the data was collected on.
  • params_file_json – Path to a JSON file with dataset parameters.
Returns:

A new Dataset record.

static get(*arg, **kw)

Get dataset with ID dataset_id

Parameters:dataset_id – The ID of a dataset to retrieve.
Returns:A Dataset record.
static list(*arg, **kw)

Retrieve a list of datasets.

Parameters:
  • experiment_id – The ID of an experiment to retrieve datasets from.
  • filters – Filters, e.g. “description=Dataset Description”
  • limit – Maximum number of results to return.
  • offset – Skip this many records from the start of the result set.
  • order_by – Order by this field.
Returns:

A list of Dataset records, encapsulated in a ResultSet object.

static update(dataset_id, description)

Update an dataset record.

class mytardisclient.models.dataset.DatasetParameter(dataset_param_json)

Bases: object

Model class for MyTardis API v1’s DatasetParameterResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static list(*arg, **kw)

List dataset parameter records in parameter set.

class mytardisclient.models.dataset.DatasetParameterSet(dataset_paramset_json)

Bases: object

Model class for MyTardis API v1’s DatasetParameterSetResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static list(*arg, **kw)

List dataset parameter sets associated with dataset ID dataset_id.

Parameters:dataset_id – The ID of the dataset to retrieve parameter sets for.
Returns:A list of DatasetParameterSet records, encapsulated in a ResultSet object`.

mytardisclient.models.datafile

Model class for MyTardis API v1’s DataFileResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

class mytardisclient.models.datafile.DataFile(datafile_json, include_metadata=True)

Bases: object

Model class for MyTardis API v1’s DataFileResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static create(dataset_id, storagebox, dataset_path, path)

Create one or more DataFile records, depending on whether the supplied path is a single file or a directory.

Parameters:
  • dataset_id – The ID of the dataset to create the datafile record(s) in.
  • storagebox – The storage box containing the datafile(s).
  • dataset_path – Only required if the supplied path to the datafile(s) is absolute (not relative). If a relative path is supplied, then dataset_path is automatically set to the first component of the relative path. The MyTardis Client will create a symlink to dataset_path in ~/.config/mytardisclient/servers/[mytardis_hostname]/ which will enable MyTardis to verify and ingest the file.
  • path – The path to a file to be represented in the DataFile record or to a directory containing the files to create records for. If the path is a relative (not absolute) path, e.g. ‘dataset1/subdir1/datafile1.txt’, then the first directory (‘dataset1’) in the path is assumed to be the local dataset path. The MyTardis Client will create a symlink to the local dataset path in ~/.config/mytardisclient/servers/[mytardis_hostname]/ which will enable MyTardis to verify and ingest the file. If the path is an absolute path, e.g. ‘/home/james/dataset1/subdir1/datafile1.txt’, then the dataset_path argument must be used to specified the dataset path, e.g. ‘/home/james/dataset1’.
static create_datafile(dataset_id, storagebox, dataset_path, file_path, return_new_datafile=True)

Create a DataFile record.

Parameters:
  • dataset_id – The ID of the dataset to create the datafile in.
  • storagebox – The storage box containing the datafile.
  • dataset_path – Only required if the supplied path to the datafile is absolute (not relative). If a relative file_path is specified, and dataset_path is not specified, then dataset_path is automatically set to the first component of the file_path. The MyTardis Client will create a symlink to dataset_path in ~/.config/mytardisclient/servers/[mytardis_hostname]/ which will enable MyTardis to verify and ingest the file.
  • file_path – The local path to the file to be represented in the DataFile record. If file_path is a relative (not absolute) path, e.g. ‘dataset1/subdir1/datafile1.txt’, then the first directory (‘dataset1’) in the file_path is assumed to be the local dataset path, which we will create a symlink to in ~/.config/mytardisclient/servers/[mytardis_hostname]/. This will enable MyTardis to verify and ingest the file. The subdirectory (‘subdir1’) to be recorded in the DataFile record(s) will be determined automatically.
Returns:

A new DataFile record.

See also: mytardisclient.models.datafile.DataFile.upload()

Suppose someone with username james generates a file called “results.dat” on a data analysis server called analyzer.example.com in the directory ~james/analysis/dataset1/. User james could grant the MyTardis server temporary access to his account on analyzer.example.com and then have MyTardis copy the file(s) into a more permanent location.

If james agrees to allow the MyTardis server to do so, it could SSHFS-mount james@analyzer.example.com:/home/james/analysis/, e.g. at /mnt/sshfs/james-anaylzer/

Then user james doesn’t need to upload results.dat, he just needs to tell MyTardis how to access it, and tell MyTardis that it is not yet in a permanent location.

MyTardis’s default storage box model generates datafile object identifiers which include a dataset description (e.g. ‘dataset1’) and a unique ID, resulting in path like ‘dataset1-123/results.dat’ for the datafile object. Because user james doesn’t want to have to create the ‘dataset1-123’ folder himself, he could entrust the MyTardis Client to do it for him.

The MyTardis administrator can create a storage box for james called “james-analyzer” which is of type “receiving”, meaning that it is a temporary location. The storage box record (which only needs to be accessed by the MyTardis administrator) would include a StorageBoxOption with key ‘location’ and value ‘/mnt/sshfs/james-analyzer’.

Once james knows the dataset ID of the dataset he wants to upload to (123 in this case), he can create a DataFile record as follows:

mytardis datafile create 123 –storagebox=james-analyzer ~/analysis/dataset1/results.dat

The file_path argument (set to ~/analysis/dataset1/results.dat) specifies the location of ‘results.dat’ on the analysis server.

To enable the MyTardis server to access (and verify) the file via SSHFS / SFTP, a symbolic link can be created in ~james/.mytardisclient/servers/[mytardis_hostname]/, named “dataset1-123” pointing to the location of ‘results.dat’, i.e. ~james/analysis/dataset1/.

static create_datafiles(dataset_id, storagebox, dataset_path, dir_path)

Create a DataFile record for each file within the dir_path directory.

Parameters:
  • dataset_id – The ID of the dataset to create the datafile record(s) in.
  • storagebox – The storage box containing the datafile(s).
  • dataset_path – Only required if the supplied dir_path is absolute (not relative). If a relative path is supplied, then dataset_path is automatically set to the first component of the relative path. The MyTardis Client will create a symlink to dataset_path in ~/.config/mytardisclient/servers/[mytardis_hostname]/ which will enable MyTardis to verify and ingest the file.
  • dir_path – The path to a directory containing file(s) to create DataFile records for. If the dir_path is relative (not absolute) path, e.g. ‘dataset1/subdir1’, then the MyTardis Client will assume that the first component of the path (e.g. ‘dataset1/’) is the local dataset path, and create a symlink to this path in ~/.config/mytardisclient/servers/[mytardis_hostname]/ which will enable MyTardis to verify and ingest its file(s). If dir_path is an absolute path, e.g. ‘/home/james/dataset1/subdir1/’, then the dataset_path argument must be used to specified the dataset path, e.g. ‘/home/james/dataset1’.
static download(datafile_id)

Download datafile with id datafile_id

Parameters:datafile_id – The ID of a datafile to download.
static exists(dataset_id, directory, filename)

If MyTardis is running with DEBUG=False, then we won’t be able detect duplicate key errors easily, we will just receive a generic HTTP 500 from the MyTardis API. This method checks whether a DataFile record already exists for the supplied dataset_id, directory and filename.

Parameters:
  • dataset_id – The ID of the dataset to check existence in.
  • directory – The directory within the dataset to check existence in.
  • filename – The filename to check for existence.
Returns:

True if a matching DataFile record already exists.

static get(*arg, **kw)

Retrieve DataFile record with id datafile_id

Parameters:datafile_id – The ID of a datafile to retrieve.
Returns:A DataFile record.
static list(*arg, **kw)

Retrieve a list of datafiles.

Parameters:
  • dataset_id – The ID of a dataset to retrieve datafiles from.
  • directory – The subdirectory within the dataset.
  • filename – The datafile’s name.
  • filters – Filters, e.g. “filename=file1.txt”
  • limit – Maximum number of results to return.
  • offset – Skip this many records from the start of the result set.
  • order_by – Order by this field.
Returns:

A list of DataFile records.

static update(datafile_id, md5sum)

Update a DataFile record.

Parameters:
  • datafile_id – The ID of a datafile to be updated.
  • md5sum – The new MD5 sum value.

This method is not usable yet, because the MyTardis API doesn’t yet allow update_detail to be performed on DataFile records.

For a large file, its upload can commence before the local MD5 sum calculation is complete, i.e. the DataFile record can be initially created with a bogus checksum which is later updated using this method.

static upload(dataset_id, storagebox, dataset_path, file_path)

Upload datafile to dataset with ID dataset_id, using HTTP POST.

Parameters:
  • dataset_id – The ID of the dataset to create the datafile in.
  • dataset_path – Only required if the supplied path to the datafile is absolute (not relative). If a relative path is supplied, e.g. ‘dataset1/subdir1/datafile1.txt’, then the dataset_path is assumed to be the first component of the relative path, leaving the remaining path components to define the directory and filename to record in the DataFile record.
  • file_path – The local path to the file to be represented in the DataFile record. If dataset_path is not specified, file_path must be a relative (not absolute) path, e.g. ‘dataset1/subdir1/datafile1.txt’.
verified

All replicas (DFOs) must be verified and there must be at least one replica (DFO).

static verify(datafile_id)

Ask MyTardis to verify a datafile with id datafile_id

Parameters:datafile_id – The ID of a datafile to be verified.
class mytardisclient.models.datafile.DataFileParameter(datafile_param_json)

Bases: object

Model class for MyTardis API v1’s DataFileParameterResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static list(*arg, **kw)

List datafile parameter records in parameter set.

Parameters:datafile_param_set – The datafile parameter set to list parameters for.
class mytardisclient.models.datafile.DataFileParameterSet(datafile_paramset_json)

Bases: object

Model class for MyTardis API v1’s DataFileParameterSetResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static list(*arg, **kw)

List datafile parameter sets associated with datafile ID datafile_id.

Parameters:datafile_id – The ID of a datafile to list parameter sets for.
Returns:A list of DatasetParameterSet records, encapsulated in a ResultSet object`.
mytardisclient.models.datafile.md5_sum(file_path, blocksize=65536)

Calculate MD5 checksum without reading the whole file into memory.

mytardisclient.models.schema

Model class for MyTardis API v1’s SchemaResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

class mytardisclient.models.schema.ParameterName(parametername_json)

Bases: object

Model class for MyTardis API v1’s ParameterNameResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static get(*arg, **kw)

Get parameter name with id parametername_id

Parameters:parametername_id – The ID of a parameter name to retrieve.
Returns:A ParameterName record.
static list(*arg, **kw)

Retrieve the list of parameter name records in a schema.

Parameters:schema_id – The ID of the schema to retrieve parameter names for.
Returns:A list of ParameterName records, encapsulated in a ResultSet object`.
class mytardisclient.models.schema.Schema(schema_json)

Bases: object

Model class for MyTardis API v1’s SchemaResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static get(*arg, **kw)

Get schema with ID schema_id

Parameters:schema_id – The ID of a schema to retrieve.
Returns:A Schema record.
static list(*arg, **kw)

Retrieve a list of schemas.

Parameters:
  • limit – Maximum number of results to return.
  • offset – Skip this many records from the start of the result set.
  • order_by – Order by this field.
Returns:

A list of Schema records, encapsulated in a ResultSet object`.

mytardisclient.models.storagebox

Model class for MyTardis API v1’s StorageBoxResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

class mytardisclient.models.storagebox.StorageBox(storage_box_json)

Bases: object

Model class for MyTardis API v1’s StorageBoxResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

static get(*arg, **kw)

Get storage box with ID storage_box_id

Parameters:storage_box_id – The ID of a storage box to retrieve.
Returns:A StorageBox record.
static list(*arg, **kw)

Retrieve a list of storage boxes.

Parameters:
  • limit – Maximum number of results to return.
  • offset – Skip this many records from the start of the result set.
  • order_by – Order by this field.
Returns:

A list of StorageBox records, encapsulated in a ResultSet object`.

class mytardisclient.models.storagebox.StorageBoxAttribute(storage_box_attribute_json)

Bases: object

Model class for MyTardis API v1’s StorageBoxAttributeResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

class mytardisclient.models.storagebox.StorageBoxOption(storage_box_option_json)

Bases: object

Model class for MyTardis API v1’s StorageBoxOptionResource. See: https://github.com/mytardis/mytardis/blob/3.7/tardis/tardis_portal/api.py

mytardisclient.models.resultset

This module contains the ResultSet class, an abstraction to represent the JSON returned by the MyTardis API, particularly for queries which return multiple records and could be subject to pagination.

class mytardisclient.models.resultset.ResultSet(model, url, json)

Bases: object

Abstraction to represent JSON returned by MyTardis API which includes a list of records and some meta information e.g. whether there are additional pages of records to retrieve.

next()

Return the next item from the ResultSet. If there are no further items, raise the StopIteration exception.

mytardisclient.views

Views for MyTardis records.

mytardisclient.views.render(data, render_format='table', display_heading=True)

Generic render function.

Calls a more specific render function depending on the data type to display (render) the data in the desired format.

Parameters:
  • data – The data to be displayed. An instance of a model class (e.g. mytardisclient.models.dataset.Dataset) or an instance of mytardisclient.models.resultset.ResultSet or an instance of mytardisclient.models.api.ApiEndpoints.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_api_endpoints(api_endpoints, render_format, display_heading=True)

Render API endpoints

Parameters:
  • api_endpoints (mytardisclient.models.api.ApiEndpoints) – The API endpoints to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for an ApiEndpoints set, setting display_heading to True ensures that a heading is displayed before the results table. The heading includes the URL resolved to perform the query.
mytardisclient.views.render_api_endpoints_as_json(api_endpoints, indent=2, sort_keys=True)

Returns JSON representation of api_endpoints.

Parameters:
  • api_endpoints (mytardisclient.models.api.ApiEndpoints) – The API endpoints to be rendered.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_api_endpoints_as_table(api_endpoints, display_heading=True)

Returns ASCII table view of api_endpoints.

Parameters:
  • api_endpoints (mytardisclient.models.api.ApiEndpoints) – The API endpoints to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for an ApiEndpoints set, setting display_heading to True ensures that a heading is displayed before the results table. The heading includes the URL resolved to perform the query.
mytardisclient.views.render_api_schema(api_schema, render_format)

Render API schema

Parameters:
mytardisclient.views.render_api_schema_as_json(api_schema, indent=2, sort_keys=True)

Returns JSON representation of API schema.

Parameters:
  • api_schema (mytardisclient.models.api.ApiSchema) – The API schema model to be displayed.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_api_schema_as_table(api_schema)

Returns ASCII table view of API schema.

Parameters:api_schema (mytardisclient.models.api.ApiSchema) – The API schema model to be displayed.
mytardisclient.views.render_datafile(datafile, render_format)

Render datafile

Parameters:
mytardisclient.views.render_datafile_as_json(datafile, indent=2, sort_keys=True)

Returns JSON representation of datafile.

Parameters:
  • datafile (mytardisclient.models.datafile.DataFile) – The datafile to be rendered.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_datafile_as_table(datafile)

Returns ASCII table view of datafile.

Parameters:datafile (mytardisclient.models.datafile.DataFile) – The datafile to be rendered.
mytardisclient.views.render_datafiles(datafiles, render_format, display_heading=True)

Render datafiles

Parameters:
  • datafiles (mytardisclient.models.resultset.ResultSet) – The ResultSet of datafiles to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_datafiles_as_json(datafiles, indent=2, sort_keys=True)

Returns JSON representation of datafiles.

Parameters:
  • datafiles (mytardisclient.models.resultset.ResultSet) – The result set of datafiles to be displayed.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_datafiles_as_table(datafiles, display_heading=True)

Returns ASCII table view of datafiles.

Parameters:
  • datafiles (mytardisclient.models.resultset.ResultSet) – The datafiles to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – Setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_dataset(dataset, render_format)

Render dataset

Parameters:
mytardisclient.views.render_dataset_as_json(dataset, indent=2, sort_keys=True)

Returns JSON representation of dataset.

Parameters:
  • dataset (mytardisclient.models.dataset.Dataset) – The dataset to be rendered.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_dataset_as_table(dataset)

Returns ASCII table view of dataset.

Parameters:dataset (mytardisclient.models.dataset.Dataset) – The dataset to be rendered.
mytardisclient.views.render_datasets(datasets, render_format, display_heading=True)

Render datasets

Parameters:
  • datasets (mytardisclient.models.resultset.ResultSet) – The ResultSet of datasets to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_datasets_as_json(datasets, indent=2, sort_keys=True)

Returns JSON representation of datasets.

Parameters:
  • datasets (mytardisclient.models.resultset.ResultSet) – The result set of datasets to be displayed.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_datasets_as_table(datasets, display_heading=True)

Returns ASCII table view of datasets.

Parameters:
  • datasets (mytardisclient.models.resultset.ResultSet) – The datasets to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – Setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_experiment(experiment, render_format)

Render experiment

Parameters:
mytardisclient.views.render_experiment_as_json(experiment, indent=2, sort_keys=True)

Returns JSON representation of experiment.

Parameters:
  • experiment (mytardisclient.models.experiment.Experiment) – The experiment to be rendered.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_experiment_as_table(experiment)

Returns ASCII table view of experiment.

Parameters:experiment (mytardisclient.models.experiment.Experiment) – The experiment to be rendered.
mytardisclient.views.render_experiments(experiments, render_format, display_heading=True)

Render experiments

Parameters:
  • experiments (mytardisclient.models.resultset.ResultSet) – The ResultSet of experiments to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_experiments_as_json(experiments, indent=2, sort_keys=True)

Returns JSON representation of experiments.

Parameters:
  • experiments (mytardisclient.models.resultset.ResultSet) – The result set of experiments to be displayed.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_experiments_as_table(experiments, display_heading=True)

Returns ASCII table view of experiments.

Parameters:
  • experiments (mytardisclient.models.resultset.ResultSet) – The experiments to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – Setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_facilities(facilities, render_format, display_heading=True)

Render facilities

Parameters:
  • facilities (mytardisclient.models.resultset.ResultSet) – The ResultSet of facilities to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_facilities_as_json(facilities, indent=2, sort_keys=True)

Returns JSON representation of facilities.

Parameters:
  • facilities (mytardisclient.models.resultset.ResultSet) – The result set of facilities to be displayed.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_facilities_as_table(facilities, display_heading=True)

Returns ASCII table view of facilities.

Parameters:
  • facilities (mytardisclient.models.resultset.ResultSet) – The facilities to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – Setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_facility(facility, render_format, display_heading=True)

Render facility

Parameters:
  • facility (mytardisclient.models.facility.Facility) – The facility to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for an ApiEndpoints set, setting display_heading to True ensures that a heading is displayed before the results table. The heading includes the URL resolved to perform the query.
mytardisclient.views.render_facility_as_json(facility, indent=2, sort_keys=True)

Returns JSON representation of facility.

Parameters:
  • facility (mytardisclient.models.facility.Facility) – The facility to be rendered.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_facility_as_table(facility, display_heading=True)

Returns ASCII table view of facility.

Parameters:
  • facility (mytardisclient.models.facility.Facility) – The facility to be rendered.
  • display_heading – When using the ‘table’ render format for an ApiEndpoints set, setting display_heading to True ensures that a heading is displayed before the results table. The heading includes the URL resolved to perform the query.
mytardisclient.views.render_instrument(instrument, render_format)

Render instrument

Parameters:
mytardisclient.views.render_instrument_as_json(instrument, indent=2, sort_keys=True)

Returns JSON representation of instrument.

Parameters:
  • instrument (mytardisclient.models.instrument.Instrument) – The instrument to be rendered.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_instrument_as_table(instrument)

Returns ASCII table view of instrument.

Parameters:instrument (mytardisclient.models.instrument.Instrument) – The instrument to be rendered.
mytardisclient.views.render_instruments(instruments, render_format, display_heading=True)

Render instruments

Parameters:
  • instruments (mytardisclient.models.resultset.ResultSet) – The ResultSet of instruments to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_instruments_as_json(instruments, indent=2, sort_keys=True)

Returns JSON representation of instruments.

Parameters:
  • instruments (mytardisclient.models.resultset.ResultSet) – The result set of instruments to be displayed.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_instruments_as_table(instruments, display_heading=True)

Returns ASCII table view of instruments.

Parameters:
  • instruments (mytardisclient.models.resultset.ResultSet) – The instruments to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – Setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_result_set(result_set, render_format, display_heading=True)

Render result set.

Calls a more specific render function depending on the type of data stored within the ResultSet to display (render) the data in the desired format.

Parameters:
  • result_set (mytardisclient.models.resultset.ResultSet) – The result set to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_schema(schema, render_format)

Render schema

Parameters:
mytardisclient.views.render_schema_as_json(schema, indent=2, sort_keys=True)

Returns JSON representation of schema.

Parameters:
  • schema (mytardisclient.models.schema.Schema) – The schema to be rendered.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_schema_as_table(schema)

Returns ASCII table view of schema.

Parameters:schema (mytardisclient.models.schema.Schema) – The schema to be rendered.
mytardisclient.views.render_schemas(schemas, render_format, display_heading=True)

Render schemas

Parameters:
  • schemas (mytardisclient.models.resultset.ResultSet) – The ResultSet of schemas to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_schemas_as_json(schemas, indent=2, sort_keys=True)

Returns JSON representation of schemas.

Parameters:
  • schemas (mytardisclient.models.resultset.ResultSet) – The result set of schemas boxes to be displayed.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_schemas_as_table(schemas, display_heading=True)

Returns ASCII table view of schemas.

Parameters:
  • schemas (mytardisclient.models.resultset.ResultSet) – The schemas to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – Setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_single_record(data, render_format)

Render single record.

Calls a more specific render function depending on the data type to display (render) the data in the desired format.

Parameters:
  • data – The data to be displayed. An instance of a model class (e.g. mytardisclient.models.dataset.Dataset).
  • render_format – The format to display the data in (‘table’ or ‘json’).
mytardisclient.views.render_storage_box(storage_box, render_format)

Render storage box

Parameters:storage_box (mytardisclient.models.storagebox.StorageBox) – The storage box to be rendered.
mytardisclient.views.render_storage_box_as_json(storage_box, indent=2, sort_keys=True)

Returns JSON representation of storage_box.

Parameters:
  • storage_box (mytardisclient.models.storagebox.StorageBox) – The storage box to be rendered.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_storage_box_as_table(storage_box)

Returns ASCII table view of storage_box.

mytardisclient.views.render_storage_boxes(storage_boxes, render_format, display_heading=True)

Render storage boxes.

Parameters:
  • storage_boxes (mytardisclient.models.resultset.ResultSet) – The ResultSet of storage boxes to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – When using the ‘table’ render format for a ResultSet containing multiple records, setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.
mytardisclient.views.render_storage_boxes_as_json(storage_boxes, indent=2, sort_keys=True)

Returns JSON representation of storage_boxes.

Parameters:
  • storage_boxes (mytardisclient.models.resultset.ResultSet) – The result set of storage boxes to be displayed.
  • indent – If indent is a non-negative integer or string, then JSON array elements and object members will be pretty-printed with that indent level.
  • sort_keys – If sort_keys is True (default: False), then the rendered JSON will be sorted by key.
mytardisclient.views.render_storage_boxes_as_table(storage_boxes, display_heading=True)

Returns ASCII table view of storage_boxes.

Parameters:
  • storage_boxes (mytardisclient.models.resultset.ResultSet) – The storage boxes to be rendered.
  • render_format – The format to display the data in (‘table’ or ‘json’).
  • display_heading – Setting display_heading to True ensures that the meta information returned by the query is summarized in a ‘heading’ before displaying the table. This meta information can be used to determine whether the query results have been truncated due to pagination.

mytardisclient.conf

Defines the singleton configuration instance of mytardisclient.models.config.Config.

It can be imported as follows:

from mytardisclient.conf import config