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.
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.
- download_output(storage_key)[source]
Return content from the DART web service based on its storage key.
- get_outputs_from_records(records)[source]
Return reader outputs corresponding to a list of records.
- 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:
- indra_world.sources.dart.client.prioritize_records(records, priorities=None)[source]
Return unique records per reader and document prioritizing by version.
- Parameters:
- 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: