3. Utilities to validate JSON-schemas and instances¶
-
jsonschema_validator.
validate_instance
(schemapath, schemafile, instancepath, instancefile, error_printing, store)[source]¶ Validate a JSON instance againsts a JSON schema.
-
jsonschema_validator.
validate_schema
(path, schema_file_name)[source]¶ Validate a JSON schema given the folder/path and file name of the schema file.
-
jsonschema_validator.
validate_schema_file
(schema_file)[source]¶ Validate a JSON schema given the schema file.
-
class
miflowcyt_validate.
FlowRepoClient
(mapping, base_schema, client_id)[source]¶ A class that provides functionality to download experiments from the FlowRepository (https://flowrepository.org/), transform the XML into JSON and validate the instances against their schema. The transformation from XML to JSON relies on the JSONBender library (https://github.com/Onyo/jsonbender).
-
static
get_mapping
(mapping_file_name)[source]¶ Build the mapping dictionary based on the given mapping file :param mapping_file_name: the name of the mapping file :return mapping: the mapping of the fields
-
get_user_content_id
(client_identifier)[source]¶ Return all IDs found in the user content XML :param client_identifier: the user content ID :return: a list of all IDs there were identified in the variable returned by the API
-
static
grab_experiment_from_api
(client_identifier, item_identifier)[source]¶ Retrieve the experimental metadata and return it as a python object :param client_identifier: the client identifier (apiKey) :param item_identifier: the item identifier that should be retrieved :return: the python object obtained from the XML
-
static
grab_user_content
(client_identifier)[source]¶ Grab all content for a given user ID as an XML and outputs it as a JSON. This method will grab all public experiments plus those only accessible to the user ID.
- Args:
- client_identifier: the user ID
- Returns
- response the dictionary containing the XML
-
make_validation
(number_of_items)[source]¶ Method to run the mapping for the given number of items
- Args
- number_of_items (int): the number of items to process
- Returns
- errors (dict): a dictionary containing the list of errors for all processed items
-
static
validate_instance_from_file
(instance, item_id, schema_name)[source]¶ Method to output the extracted JSON into a file and validate it against the given schema :param instance: the instance to output into a file :param item_id: the instance ID needed to create the file name :param schema_name: the schema to check against :return errors: a list of fields that have an error for this instance
-
static
-
class
miflowcyt_validate.
FlowRepoClient
(mapping, base_schema, client_id)[source] A class that provides functionality to download experiments from the FlowRepository (https://flowrepository.org/), transform the XML into JSON and validate the instances against their schema. The transformation from XML to JSON relies on the JSONBender library (https://github.com/Onyo/jsonbender).
-
static
get_mapping
(mapping_file_name)[source] Build the mapping dictionary based on the given mapping file :param mapping_file_name: the name of the mapping file :return mapping: the mapping of the fields
-
get_user_content_id
(client_identifier)[source] Return all IDs found in the user content XML :param client_identifier: the user content ID :return: a list of all IDs there were identified in the variable returned by the API
-
static
grab_experiment_from_api
(client_identifier, item_identifier)[source] Retrieve the experimental metadata and return it as a python object :param client_identifier: the client identifier (apiKey) :param item_identifier: the item identifier that should be retrieved :return: the python object obtained from the XML
-
static
grab_user_content
(client_identifier)[source] Grab all content for a given user ID as an XML and outputs it as a JSON. This method will grab all public experiments plus those only accessible to the user ID.
- Args:
- client_identifier: the user ID
- Returns
- response the dictionary containing the XML
-
make_validation
(number_of_items)[source] Method to run the mapping for the given number of items
- Args
- number_of_items (int): the number of items to process
- Returns
- errors (dict): a dictionary containing the list of errors for all processed items
-
static
validate_instance_from_file
(instance, item_id, schema_name)[source] Method to output the extracted JSON into a file and validate it against the given schema :param instance: the instance to output into a file :param item_id: the instance ID needed to create the file name :param schema_name: the schema to check against :return errors: a list of fields that have an error for this instance
-
static