Running models

Once you have configured the model, you use the client to run the model. If you have more than one server specified in the configuration file, you can specify which server to run on. In addition, you can provide a string tag to label the model results. This is useful when you want to group results together within a project and run the same models multiple times with different inputs for instance.

Note: The same model run with the same tag, within the same project will overwrite the old results.

get_model method:
Parameter Optional / default Comment
model_name No The name of the model as specified in the model specification
server_id Yes / “default” A particular server ID
model_specification Yes / None A model specification can be provided directly. In this case, no call will be made to the NoM Server

This model returns a Model object.

You can check the is_valid_model flag on this object if you want to confirm that a valid model was returned. If this flag is false, you can inspect the message property of the model object for the error message.

Many models have pre-requisites that need to run to provide appropriate inputs. An example is AP-8 requiring outputs from the SAPRE model.

To determine if a particular model can run:

ae8ap8_model = nom_client.get_model("ae8ap8")
>>> {'valid': 'false', 'message': "External input (trajectory) not supplied for model 'ae8ap8'."}

sapre_model = nom_client.get_model("sapre")
sapre_result = nom_client.run_model(sapre_model)
ae8ap8_model.set_external_input(external_input_name="trajectory", external_input=sapre_result)

>>>{'valid': 'true', 'message': ''}

This method returns a python dictionary with ‘valid’ and ‘message’ keys. This is useful to determine if the model pre-requisites have been provided (such as external inputs etc)

run_model method:
Parameter Optional / default Comment
model No The model object (as returned by the get_model method
server_id Yes / “default” A particular server ID
tag No / “default” A tag to label or namespace the results

When the client runs a model, it blocks for a small (configurable) amount of time. If the model completed within this time a ModelRun object is returned. After this cut-off, the server returns the run_id of the model running.

By default, the client then polls for the result using the run_id until the model completes.

sapre_results = nom_client.run_model(sapre_model)
>>> {"model_name": "sapre", "status": 0, "message": "success", "result_count": 2, "output_files": 3}

Status Comment
RUNNING The model is still running on the server
COMPLETED The model has completed. **Note**: This does imply that the results are valid or correct in any way
FAILED The model has failed. Check the message property for further information
NOT_RUN The model run has been created but not run yet

This method returns a ModelRun object containing the results.

Access to this repository can be requested by emailing