diff --git a/test_requirements.in b/test_requirements.in index e75a81471..453e2701c 100644 --- a/test_requirements.in +++ b/test_requirements.in @@ -1,7 +1,6 @@ docker~=4.0 pytest~=5.2 pytest-xdist~=1.26 # Parallelises the test-runs -ruamel.yaml~=0.15 pytest-mock~=1.11 pytest-mypy~=0.3 pytest-timeout~=1.3 diff --git a/test_requirements.txt b/test_requirements.txt index 2b5111858..baf2c4a91 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -80,8 +80,6 @@ qtconsole==4.5.5 # via jupyter regex==2019.8.19 # via black requests==2.22.0 # via adal, docker, responses responses==0.10.6 -ruamel.yaml.clib==0.2.0 # via ruamel.yaml -ruamel.yaml==0.16.5 scikit-learn==0.21.3 scipy==1.3.1 # via scikit-learn send2trash==1.5.0 # via notebook diff --git a/tests/conftest.py b/tests/conftest.py index 0402f74e9..400185d1f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,7 +10,7 @@ import docker import pytest import requests -import ruamel.yaml +import yaml import numpy as np from gordo_components import serializer @@ -92,7 +92,7 @@ def trained_model_directory( model_dir = os.path.join(collection_dir, gordo_name) os.makedirs(model_dir, exist_ok=True) - definition = ruamel.yaml.load( + definition = yaml.safe_load( """ gordo_components.model.anomaly.diff.DiffBasedAnomalyDetector: base_estimator: @@ -102,8 +102,7 @@ def trained_model_directory( - gordo_components.model.models.KerasAutoEncoder: kind: feedforward_hourglass memory: - """, - Loader=ruamel.yaml.Loader, + """ ) model = serializer.pipeline_from_definition(definition) X = np.random.random(size=len(sensors) * 10).reshape(10, len(sensors)) diff --git a/tests/gordo_components/serializer/test_serializer_into_definition.py b/tests/gordo_components/serializer/test_serializer_into_definition.py index eb04642e9..b7031f59b 100644 --- a/tests/gordo_components/serializer/test_serializer_into_definition.py +++ b/tests/gordo_components/serializer/test_serializer_into_definition.py @@ -2,8 +2,8 @@ import unittest import logging -import ruamel.yaml -import io +import yaml +import json import pydoc from sklearn.pipeline import Pipeline, FeatureUnion @@ -123,32 +123,31 @@ def setUp(self): def test_pipeline_into_definition(self): - expected_definition = ( - """ + expected_definition = """ sklearn.pipeline.Pipeline: - memory: + memory: null steps: - sklearn.decomposition.pca.PCA: copy: true iterated_power: auto n_components: 2 - random_state: + random_state: null svd_solver: auto tol: 0.0 whiten: false - sklearn.pipeline.FeatureUnion: - n_jobs: + n_jobs: null transformer_list: - sklearn.decomposition.pca.PCA: copy: true iterated_power: auto n_components: 3 - random_state: + random_state: null svd_solver: auto tol: 0.0 whiten: false - sklearn.pipeline.Pipeline: - memory: + memory: null steps: - sklearn.preprocessing.data.MinMaxScaler: copy: true @@ -159,33 +158,28 @@ def test_pipeline_into_definition(self): algorithm: randomized n_components: 2 n_iter: 5 - random_state: + random_state: null tol: 0.0 verbose: false - transformer_weights: + transformer_weights: null verbose: false - gordo_components.model.models.KerasAutoEncoder: kind: feedforward_hourglass verbose: false - """.rstrip() - .strip() - .replace(" ", "") - ) + """ - for pipe in self.variations_of_same_pipeline: + expected_definition = yaml.safe_load(expected_definition) - definition = pipeline_into_definition(pipe) + for pipe in self.variations_of_same_pipeline: - # Using ruamel over PyYaml, better output option support - stream = io.StringIO() - ruamel.yaml.dump(definition, stream, Dumper=ruamel.yaml.RoundTripDumper) - stream.seek(0) + definition = pipeline_into_definition( + pipeline_from_definition(pipeline_into_definition(pipe)) + ) - current_output = stream.read().rstrip().strip().replace(" ", "") self.assertEqual( - current_output, - expected_definition, - msg=f"Failed output:\n{current_output}\nExpected:----------------\n{expected_definition}", + json.dumps(definition), + json.dumps(expected_definition), + msg=f"Failed output:\n{definition}\nExpected:----------------\n{expected_definition}", ) def test_into_from(self): @@ -296,7 +290,7 @@ def test_from_into(self): memory: verbose: false """ - definition = ruamel.yaml.load(definition, Loader=ruamel.yaml.Loader) + definition = yaml.safe_load(definition) pipe = pipeline_from_definition(definition) pipeline_into_definition(pipe)