openlayer.validators.dataset_validators.DatasetValidator#

class openlayer.validators.dataset_validators.DatasetValidator(dataset_config_file_path=None, dataset_config=None, dataset_file_path=None, dataset_df=None)#

Validates the dataset and its arguments.

Either the dataset_file_path or the dataset_df must be provided (not both).

Either the dataset_config_file_path or the dataset_config must be provided (not both).

Parameters
dataset_config_file_pathstr, optional

The path to the dataset_config.yaml file.

dataset_configdict, optional

The dataset_config as a dictionary.

dataset_file_pathstr, optional

The path to the dataset file.

dataset_dfpd.DataFrame, optional

The dataset to validate.

Examples

Let’s say we have a dataset_config.yaml file and a dataset.csv file in the current directory.

To ensure they are in the format the Openlayer platform expects to use the openlayer.OpenlayerClient.add_dataset(), we can use the DatasetValidator class as follows:

>>> from openlayer.validators import dataset_validators
>>>
>>> dataset_validator = dataset_validators.DatasetValidator(
...     dataset_config_file_path="dataset_config.yaml",
...     dataset_file_path="dataset.csv",
... )
>>> dataset_validator.validate()

Alternatively, if we have a dataset_config.yaml file in the current directory and a dataset_df DataFrame, we can use the DatasetValidator class as follows:

>>> from openlayer.validators import dataset_validators
>>>
>>> dataset_validator = dataset_validators.DatasetValidator(
...     dataset_config_file_path="dataset_config.yaml",
...     dataset_df=dataset_df,
... )
>>> dataset_validator.validate()

Methods

validate:

Runs all dataset validations.