mmbse_client.mmbse module

class mmbse_client.mmbse.APIClient(base_url: str, api_token: str)[source]

Bases: object

A generic Rest API wrapper

delete(endpoint: str) Response[source]
Send a DELETE request to the API.

DELETE requests are used for deleting existing data.

Parameters:

endpoint – The API endpoint

Returns:

The response from the API

get(endpoint: str, params: Optional[dict] = None) Response[source]
Send a GET request to the API.

GET requests are used for retrieving data from the API.

Parameters:
  • endpoint – The API endpoint

  • params – The query parameters

Returns:

The response from the API

post(endpoint: str, data: Optional[dict] = None, files=None) Response[source]
Send a POST request to the API.

POST requests are used for creating new data.

Parameters:
  • endpoint – The API endpoint

  • data – The data to send in the request body

Returns:

The response from the API

post_file(endpoint: str, data: Optional[dict] = None, files=None) Response[source]
Send a POST request to the API.

POST requests are used for creating new data.

Parameters:
  • endpoint – The API endpoint

  • data – The data to send in the request body

Returns:

The response from the API

put(endpoint: str, data: Optional[dict] = None) Response[source]
Send a PUT request to the API.

PUT requests are used for updating existing data.

Parameters:
  • endpoint – The API endpoint

  • data – The data to send in the request body

Returns:

The response from the API

class mmbse_client.mmbse.MMBSE(api_token: str, base_url: str = 'https://mmbse.app.cern.ch/api')[source]

Bases: APIClient

A wrapper for the MMBSE REST API

add_iteration(model, execution_type, file, description, output_files, output_params, visuals, auto_report, report_alternive)[source]
add_query(model, query_name, return_type, func)[source]
add_visual(model)[source]
check_cache(model)[source]
create_model(system: str, name: str, description: str, type: str, design_step: str, comment: str = '', inputs=None, outputs=None) MMBSE_Model[source]

Create a new model in the MMBSE API and associate it with a system.

create_model_output_parameter(model: str, name: str, value: str) Response[source]

Create a new output parameter for a specific model in the MMBSE API

Parameters:
  • model – The name or ID of the model

  • name – The name of the output parameter

  • value – The value of the output parameter

Returns:

The response from the API

create_system(name: str, type: str, description: str = '', tags: Optional[List[str]] = None, image_1=None, image_2=None, image_3=None, owner: str = '', official_system_references: Optional[List[str]] = None) Dict[str, str][source]

Create a new system in the MMBSE API.

This method sends a POST request to the MMBSE API to create a new system with the provided details.

Parameters:
  • name – The name of the system. This is a required parameter.

  • type – The type of the system. This is a required parameter.

  • description – A brief description of the system. This is an optional parameter with a default value of an empty string.

  • tags – A list of tags associated with the system. This is an optional parameter with a default value of None.

  • image_1 – The URL of the first image associated with the system. This is an optional parameter with a default value of None.

  • image_2 – The URL of the second image associated with the system. This is an optional parameter with a default value of None.

  • image_3 – The URL of the third image associated with the system. This is an optional parameter with a default value of None.

  • owner – The owner of the system. This is an optional parameter with a default value of an empty string.

  • official_system_references – A list of official system references. This is an optional parameter with a default value of None.

Returns:

A dictionary containing the response from the API. The dictionary includes details of the created system.

delete_model(model: str) None[source]

Delete a model

Parameters:

system – The name or ID of the system

delete_system(system: str) None[source]

Delete a system

Parameters:

system – The name or ID of the system

static download_file(name: str, url: str) None[source]

Download an input file from the API

Parameters:
  • name – The name of the file

  • url – The URL of the file

Returns:

The file contents

download_model_input_files(model: str) list[int][source]

Download input files for a specific model from the API

Parameters:

model – The name or ID of the model

get_cached_results()[source]
get_model(model: str) Dict[str, str][source]

Retrieve a specific model from the API

Parameters:

model – The name or ID of the model

Returns:

A dictionary containing the model information

get_model_input_file_list(model: str) Response[source]

Retrieve a list of input files for a specific model from the API

Parameters:

model – The name or ID of the model

Returns:

A list of input files

get_model_output_file_list(model: str) Response[source]

Retrieve a list of output files for a specific model from the API

Parameters:

model – The name or ID of the model

Returns:

A list of output files

get_model_output_parameter_list(model: str) Response[source]

Retrieve a list of output parameters for a specific model from the API

Parameters:

model – The name or ID of the model

Returns:

A list of output parameters

get_model_output_parameter_value(model: str, parameter_name: str) Response[source]

Retrieve the value of an output parameter for a specific model from the API

Parameters:
  • model – The name or ID of the model

  • parameter_name – The name of the output parameter

Returns:

The value of the output parameter

get_model_roxie_data_filename(model: str) Optional[str][source]
get_system(system: Union[str, int]) Dict[str, str][source]

Retrieve a specific system from the API

Parameters:

system – The name or ID of the system

Returns:

A dictionary containing the system information

get_system_model(system: Union[str, int], model_name: str) Dict[str, str][source]

Retrieve a specific system model from the API

Parameters:
  • system – The name or ID of the system

  • model_name – The name of the model

Returns:

A dictionary containing the model information

get_system_models(system: Union[str, int]) List[str][source]

Retrieve a list of models for a specific system from the API

Parameters:

system – The name or ID of the system

Returns:

A list of model names

get_systems() Dict[str, str][source]

Retrieve a dictionary of systems from the API

Returns:

A dictionary containing all systems in the database

get_user_details() Response[source]

Retrieve details of the currently authenticated user from the API

Returns:

The response from the API

is_authenticated() bool[source]

Check if the user is logged in

Returns:

True if the user is logged in, False otherwise

iteration_add_values(model_iteration, output_files, output_params, visuals, auto_report, report_alternive)[source]
load_artefact(model, artefact, iteration='latest')[source]
load_model(system, modelname) MMBSE_Model[source]
load_query(model, query, iteration='latest')[source]
upload_model_file(mode: str, model: str, name: str, file_path: str) Response[source]

Upload an output file for a specific model to the API

Parameters:
  • mode – The mode of the file (input or output)

  • model – The name or ID of the model

  • name – The name of the file

  • file_path – The path of the file to upload

Returns:

The response from the API

upload_model_input_file(model: str, name: str, file_path: str) Response[source]

Upload an input file for a specific model to the API

Parameters:
  • model – The name or ID of the model

  • name – The name of the file

  • file_path – The path of the file to upload

Returns:

The response from the API

upload_model_output_file(model: str, name: str, file_path: str) Response[source]

Upload an output file for a specific model to the API

Parameters:
  • model – The name or ID of the model

  • name – The name of the file

  • file_path – The path of the file to upload

Returns:

The response from the API

class mmbse_client.mmbse.MMBSE_Model(model_id: int, name: str, artefacts: List[str], queries: Dict[str, type], output_parameters: Dict[str, str], input_parameters: Dict[str, str], input_artefacts: List[str], input_dependencies: Dict[str, ForwardRef('MMBSE_Model')])[source]

Bases: object

artefacts: List[str]
input_artefacts: List[str]
input_dependencies: Dict[str, MMBSE_Model]
input_parameters: Dict[str, str]
model_id: int
name: str
output_parameters: Dict[str, str]
queries: Dict[str, type]
mmbse_client.mmbse.as_file(data: str)[source]

Return string data as a file accessible by target