Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch yaml load to safe_load #169

Merged
merged 1 commit into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions descqa/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# DESCQA Validation Tests

This directory hosts the validation tests for DESCQA. This README explains the technical aspects of writting a DESCQA validation test.
This directory hosts the validation tests for DESCQA. This README explains the technical aspects of writting a DESCQA validation test.

## How to write a DESCQA validation test

When you arrive here, you should already know how to access [GCRCatalogs](https://github.com/LSSTDESC/gcr-catalogs) and have a Jupyter notebook or a Python script that runs the test you want to integrate into DESCQA.
When you arrive here, you should already know how to access [GCRCatalogs](https://github.com/LSSTDESC/gcr-catalogs) and have a Jupyter notebook or a Python script that runs the test you want to integrate into DESCQA.

Since the DESCQA framework takes care of *running* your test, when you implement a DESCQA, you only implement a class with specific methods that contain the test. In other words, consider a "DESCQA manager" who will run the following code:

```python
with open('configs/your_test_name.yaml') as f:
test_options = yaml.load(f)
test_options = yaml.safe_load(f)

test = YourTestClass(**test_options)

for catalog_name in available_catalogs:
catalog_instance = GCRCatalogs.load_catalog(catalog_name)
output_dir = os.path.join(base_output_dir, catalog_name)
test_result = test.run_on_single_catalog(catalog_instance, catalog_name, output_dir)

test.conclude_test(base_output_dir)
```

Your job is to implement `YourTestClass`, which would be a subclass of `BaseValidationTest`, and to implement the following member methods in `YourTestClass`:

- `__init__`: Should set up the test (getting configs, reading in data etc.).
- `run_on_single_catalog`: Should run the test on one catalog. Should return `TestResult` instance.
- `conclude_test`: Should conclude the test (saving summary plots etc.).
- `__init__`: Should set up the test (getting configs, reading in data etc.).
- `run_on_single_catalog`: Should run the test on one catalog. Should return `TestResult` instance.
- `conclude_test`: Should conclude the test (saving summary plots etc.).

See [example_test.py](example_test.py) for an example.


Each validation test is specified by a YAML config file that sits in the `configs` subdirectory. The YAML config file specifies all the test options and the subclass used to run the test.
Each validation test is specified by a YAML config file that sits in the `configs` subdirectory. The YAML config file specifies all the test options and the subclass used to run the test.

The `data` subdirectory hosts small data files that validation tests need, and can be accessed by `self.data_dir`.

2 changes: 1 addition & 1 deletion descqa/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def load_yaml(yaml_file):
Load *yaml_file*. Ruturn a dictionary.
"""
with open(yaml_file) as f:
config = yaml.load(f)
config = yaml.safe_load(f)
return config


Expand Down
2 changes: 1 addition & 1 deletion v1/GCRCatalogs/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def load_yaml(yaml_file):
Load *yaml_file*. Ruturn a dictionary.
"""
with open(yaml_file) as f:
config = yaml.load(f)
config = yaml.safe_load(f)
return config


Expand Down
2 changes: 1 addition & 1 deletion v1/descqa/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def load_yaml(yaml_file):
Load *yaml_file*. Ruturn a dictionary.
"""
with open(yaml_file) as f:
config = yaml.load(f)
config = yaml.safe_load(f)
return config


Expand Down