nom_client.nom_client API documentation

Module nom_client.nom_client

Classes

class NoMClient (project_name: str = 'default', results_repository: Union[nom_client.repository.result_repository.ResultRepository, NoneType] = None, client_configuration=None, default_server_id: Union[str, NoneType] = None, interactive: Union[bool, NoneType] = True, persist_results: Union[bool, NoneType] = False, use_caching: Union[bool, NoneType] = False, debug_output: Union[bool, NoneType] = False, clean_results: Union[bool, NoneType] = True, return_results: Union[bool, NoneType] = True)

Client to run models on a 'Network of models' server.

Args

project_name
The name of the project to use for the model runs (optional).
client_configuration
The location of the NoM configuration file.
default_server_id
The name of the default server ID to use.

Methods

def clean_results(self, project_name='default', model_name=None, tag='default', run_id=None, server_id: str = None)

Clean/remove results from local storage.

Args

project_name : str
The name of the project (optional).
model_name : str
The name of the model (optional).
tag : str
The namespace tag (optional).
run_id : str
An ID of a model run (optional).
server_id : str
An ID of a server (optional).
def get_client_configuration_message(self) ‑> str

Get the client configuration message.

Returns bool: The configuration message.

def get_default_server(self) ‑> str

Get the default server ID.

Returns

str
the default server id
def get_file_outputs(self, model_run_name: str) ‑> List[Dict]

Return the result file contents (if any).

Args

model_run_name : str
model run name.

Returns

Dict[str, List[str]]
Dictionary of file results.
def get_model(self, model_name: str = None, version: Union[str, NoneType] = 'latest', server_id: Union[str, NoneType] = None, model_specification: Union[dict, str] = None) ‑> nom_client.model.Model

Return a model instance from a NoM server.

Args

model_name
(optional) the name of the model
version
(optional) the spec version
server_id
(optional) the ID of the NoM server. If no server ID is provided, the default value is used
model_specification
(optional) construct model from a local specification. If this is specified,

the model name and server ID is ignored

Returns

Model
The model object
def get_model_categories(self) ‑> dict

Returns a nested dictionary of model categories discovered on the registered NoM servers.

Returns

Dict[str,str]
Category dictionary
def get_model_run_by_id(self, run_id: str, server_id: str = None, include_data: bool = True) ‑> Union[ModelRun, NoneType]

Get the model run/result for a run ID.

Args

run_id : str
the run ID
server_id : str
The server ID (optional).
include_data : bool
Include the data in the returned results (optional).

Returns

ModelRun
The model run (if found).
def get_model_runs(self, server_id: str = None, run_ids=None, model_names=None, project_names=None, tags=None, include_data=True) ‑> List[ModelRun]

Get the model run for a given run name.

:param server_id: (optional) the server ID :param run_ids: (optional) run ID or list of run IDs :param model_names: (optional) model name or list of model names :param project_names: (optional) project name or list of project names :param tags: (optional) tag or list of tags :param include_data: return data or not :return: list of model runs

def get_model_specification(self, model_name, version: str = 'latest', server_id: Union[str, NoneType] = None) ‑> Dict[~AnyStr, Dict]

Returns a model specifications..

:param model_name: (optional) the model name :param version: (optional) the model version :param server_id: (optional) the ID of the NoM server :returns: model specification

def get_model_specifications(self, model_name: Union[str, NoneType] = None, version: Union[str, NoneType] = 'latest', server_id: Union[str, NoneType] = None, categories: Union[List[str], NoneType] = None, keywords: Union[List[str], NoneType] = None, detail_level: str = 'complete') ‑> Dict[~AnyStr, Dict]

Returns a dictionary of model specifications for the registered NoM servers.

Args

model_name : str
The name of the model (optional).
version : str
The spec version (only used if model name specified) (optional).
server_id : str
The ID of the NoM server (optional).
categories : List[str]
List of categories (ANDed) (optional).
keywords : List[str]
List of keywords (ANDed) (optional).
detail_level : str
'all' (default), 'inputs' or 'outputs'

Returns

Dict[str, Dict]
Dictionary of model specifications.
def get_model_status(self, run_id: str, server_id: str = None)
def get_project_name(self) ‑> str

Returns the current project name.

Returns

str
The project name
def get_taxonomy(self)

Returns the taxonomy data.

Returns

The taxonomy data

def has_model(self, model_name: str, server_id: Union[str, NoneType] = None) ‑> bool

Check the existence of a named model on a named NoM server.

Args

model_name
the name of the model
server_id
(optional) the ID of the NoM server

Returns

bool
True if the model exists.
def is_valid_configuration(self) ‑> bool

Is the client configuration valid?

Returns

bool
valid configuration?
def list_models(self, server_id: str = None, categories: List[str] = None, keywords: List[str] = None) ‑> Dict[~AnyStr, ~AnyStr]

Returns a dictionary of models discovered on the registered NoM servers.

Args

server_id : str
The ID of the NoM server (optional).
categories : List[str]
List of categories (optional).
keywords : List[str]
List of keywords (optional).

Returns

List
List of models.
def run_model(self, model: Union[Dict, nom_client.model.Model] = None, server_id: str = None, tag: str = 'default', debug: bool = False, model_timeout=10, persist_result: bool = True, wait_for_result: bool = True, return_results=None) ‑> ModelRun

Run a model.

Args

model : Union[Dict, Model]
The model to run.
server_id : str
The ID of the NoM server (optional).
tag : str
A label to tag the results (optional).
debug : bool
Print debug info if any (optional).
model_timeout : float
Time out for the futures option (optional).
persist_result : bool
Persist this result locally (optional).
wait_for_result : bool
Block the client and wait for long running results (optional).
return_results : bool
DOption to not return results. Useful for model results used as external inputs to further models (optional).

Returns

ModelRun
The model run results.
def run_pipeline(self, pipeline: Dict, tag: str = 'default')
def set_default_server(self, default_server_id: str) ‑> NoneType

Set the default server ID.

Parameters: - default_server_id (str): The ID of the default server to set.

Returns: None

def set_project_name(self, project_name: str) ‑> NoneType

Set the project name.

Args

project_name
The name of the project.
def status(self) ‑> Dict[~AnyStr, Dict]

Get the status of the registered NoM servers.

Returns

Dict[AnyStr, Dict]
Returns the status of all registered NoM servers.
def write_output_files(self, model_run_name: str = None, file_key: str = None, location: str = None) ‑> NoneType

Write out the file contents of the model run results.

Args

model_run_name : str
The name of the model run (optional).
file_key : str
The file key (optional).
location : str
The location to write to (optional).
class PipelineRunner (pipeline_params: Dict, nom_client_, tag: str = 'default')

Methods

def analysis(self)
def run_model(self, domain, result_name, model_name: str, external_inputs, params, file_uploads: None)
def runner(self)