DART (indra_world.sources.dart)

API (indra_world.sources.dart.api)

indra_world.sources.dart.api.get_record_key(rec)[source]

Return a key for a DART record for purposes of deduplication.

indra_world.sources.dart.api.get_unique_records(recs)[source]

Deduplicate DART records based on an identifier key.

indra_world.sources.dart.api.print_record_stats(recs)[source]

Print statistics for a list of DART records.

Client (indra_world.sources.dart.client)

A client for accessing reader output from the DART system.

class indra_world.sources.dart.client.DartClient(storage_mode='web', dart_url=None, dart_uname=None, dart_pwd=None, local_storage=None)[source]

A client for the DART web service with optional local storage.

Parameters:
  • storage_mode (Optional[str]) – If web, the configured DART URL and credentials are used to communicate with the DART web service. If local, a local storage is used to access and store reader outputs.

  • dart_url (Optional[str]) – The DART service URL. If given, it overrides the DART_WM_URL configuration value.

  • dart_uname (Optional[str]) – The DART service user name. If given, it overrides the DART_WM_USERNAME configuration value.

  • dart_pwd (Optional[str]) – The DART service password. If given, it overrides the DART_WM_PASSWORD configuration value.

  • local_storage (Optional[str]) – A path that points to a folder for local storage. If the storage_mode is web, this local_storage is used as a local cache. If the storage_mode is local, it is used as the primary location to access reader outputs. If given, it overrides the INDRA_WM_CACHE configuration value.

cache_record(record, overwrite=False)[source]

Download and cache a given record in local storage.

Parameters:

record (dict) – A DART record.

cache_records(records, overwrite=False)[source]

Download and cache a list of records in local storage.

Parameters:

records (list[dict]) – A list of DART records.

download_output(storage_key)[source]

Return content from the DART web service based on its storage key.

Parameters:

storage_key (str) – A DART storage key.

Returns:

The content corresponding to the storage key.

Return type:

str

get_local_storage_path(record)[source]

Return the local storage path for a DART record.

get_ontology(ontology_id)[source]

Return the DART ontology record JSON for the given ontology ID.

get_ontology_graph(ontology_id)[source]

Return the ontology graph for the given ontology ID.

get_output_from_record(record)[source]

Return reader output corresponding to a single record.

Parameters:

record (dict) – A single DART record.

Returns:

The reader output corresponding to the given record.

Return type:

str

get_outputs_from_records(records)[source]

Return reader outputs corresponding to a list of records.

Parameters:

records (list of dict) – A list of records returned from the reader output query.

Returns:

A two-level dict of reader output keyed by reader and then document id.

Return type:

dict(str, dict)

get_reader_output_records(readers=None, versions=None, document_ids=None, timestamp=None, tenant=None, ontology_id=None, unique=False)[source]

Return reader output metadata records by querying the DART API

Query json structure:

{“readers”: [“MyAwesomeTool”, “SomeOtherAwesomeTool”], “versions”: [“3.1.4”, “1.3.3.7”], “document_ids”: [“qwerty1234”, “poiuyt0987”], “timestamp”: {“before”: “yyyy-mm-ddThh:mm:ss”, “after”: “yyyy-mm-ddThh:mm:ss”}}

Parameters:
  • readers (list) – A list of reader names

  • versions (list) – A list of versions to match with the reader name(s)

  • document_ids (list) – A list of document identifiers

  • timestamp (dict("before"|"after",str)) – The timestamp string must be formatted “yyyy-mm-ddThh:mm:ss”.

  • tenant (Optional[str]) – Return only records for the given tenant.

  • ontology_id (Optional[str]) – Return only records for the given ontology ID.

  • unique (Optional[bool]) – If true, records that are duplicates are collapsed. Default: False.

Returns:

The JSON payload of the response from the DART API

Return type:

dict

get_reader_versions(reader)[source]

Return the available versions for a given reader.

get_tenant_ontology(tenant_id, version=None)[source]

Return the DART ontology record JSON for the given tenant ID and optional version.

get_tenant_ontology_graph(tenant_id, version=None)[source]

Return the ontology graph for the given tenant ID and optional version.

indra_world.sources.dart.client.prioritize_records(records, priorities=None)[source]

Return unique records per reader and document prioritizing by version.

Parameters:
  • records (list of dict) – A list of records returned from the reader output query.

  • priorities (dict of list) – A dict keyed by reader names (e.g., cwms, eidos) with values representing reader versions in decreasing order of priority.

Returns:

records – A list of records that are unique per reader and document, picked by version priority when multiple records exist for the same reader and document.

Return type:

list of dict