Skip to content

Commit

Permalink
MRG: Merge pull request #106 from octue/refactor/remove-deprecated-code
Browse files Browse the repository at this point in the history
Remove deprecated code
  • Loading branch information
cortadocodes authored May 16, 2022
2 parents 2eab418 + 2ce7dd6 commit cca1bde
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 143 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="twined",
version="0.4.1",
version="0.5.0",
py_modules=[],
install_requires=["jsonschema ~= 4.4.0", "python-dotenv"],
url="https://www.github.com/octue/twined",
Expand Down
49 changes: 0 additions & 49 deletions tests/test_manifest_strands.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,52 +349,3 @@ def test_error_raised_if_multiple_datasets_have_same_name(self):

with self.assertRaises(KeyError):
twine.validate_input_manifest(source=input_manifest)

def test_deprecation_warning_issued_and_datasets_format_translated_if_datasets_given_as_list(self):
"""Test that, if datasets are given as a list (the old format), a deprecation warning is issued and the list
is translated to a dictionary (the new format).
"""
twine = """
{
"input_manifest": {
"datasets": {
"met_mast_data": {
"purpose": "A dataset containing meteorological mast data"
}
}
}
}
"""

input_manifest = """
{
"id": "8ead7669-8162-4f64-8cd5-4abe92509e17",
"datasets": [
{
"id": "7ead7669-8162-4f64-8cd5-4abe92509e19",
"name": "met_mast_data",
"tags": {},
"labels": [],
"files": []
}
]
}
"""

twine = Twine(source=twine)

with self.assertWarns(DeprecationWarning):
manifest = twine.validate_input_manifest(source=input_manifest)

self.assertEqual(
manifest["datasets"],
{
"met_mast_data": {
"id": "7ead7669-8162-4f64-8cd5-4abe92509e19",
"name": "met_mast_data",
"tags": {},
"labels": [],
"files": [],
}
},
)
37 changes: 1 addition & 36 deletions tests/test_twine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from twined import MANIFEST_STRANDS, Twine, exceptions
from twined import Twine, exceptions
from .base import BaseTestCase


Expand Down Expand Up @@ -123,38 +123,3 @@ def test_available_strands_properties(self):
)

self.assertEqual(twine.available_manifest_strands, {"output_manifest"})

def test_deprecation_warning_issued_if_datasets_not_given_as_dictionary_in_manifest_strands(self):
"""Test that, if datasets are given as a list in the manifest strands, a deprecation warning is issued and the
list (the old form) is converted to a dictionary (the new form).
"""
for manifest_strand in MANIFEST_STRANDS:
with self.subTest(manifest_strand=manifest_strand):
invalid_twine = (
"""
{
"%s": {
"datasets": [
{
"key": "met_mast_data",
"purpose": "A dataset containing meteorological mast data"
}
]
}
}
"""
% manifest_strand
)

with self.assertWarns(DeprecationWarning):
twine = Twine(source=invalid_twine)

self.assertEqual(
getattr(twine, manifest_strand)["datasets"],
{
"met_mast_data": {
"key": "met_mast_data",
"purpose": "A dataset containing meteorological mast data",
}
},
)
3 changes: 3 additions & 0 deletions twined/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""A subpackage containing any translations from deprecated code to new code for deprecations that haven't been phased
out yet. See https://github.com/octue/twined/issues/102.
"""
23 changes: 0 additions & 23 deletions twined/migrations/manifest.py

This file was deleted.

22 changes: 0 additions & 22 deletions twined/migrations/twine.py

This file was deleted.

12 changes: 0 additions & 12 deletions twined/twine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from dotenv import load_dotenv
from jsonschema import ValidationError, validate as jsonschema_validate

import twined.migrations.manifest as manifest_migrations
import twined.migrations.twine as twine_migrations
from . import exceptions
from .utils import load_json, trim_suffix

Expand Down Expand Up @@ -60,13 +58,6 @@ def _load_twine(self, source=None):
else:
raw_twine = self._load_json("twine", source, allowed_kinds=("file-like", "filename", "string", "object"))

for strand in set(MANIFEST_STRANDS) & raw_twine.keys():
if isinstance(raw_twine[strand]["datasets"], list):
raw_twine[strand]["datasets"] = twine_migrations.convert_manifest_datasets_from_list_to_dictionary(
datasets=raw_twine[strand]["datasets"],
strand=strand,
)

self._validate_against_schema("twine", raw_twine)
self._validate_twine_version(twine_file_twined_version=raw_twine.get("twined_version", None))
return raw_twine
Expand Down Expand Up @@ -179,9 +170,6 @@ def _validate_manifest(self, kind, source, cls=None, **kwargs):
inbound = False
data = data.to_primitive()

if isinstance(data["datasets"], list):
data["datasets"] = manifest_migrations.convert_dataset_list_to_dictionary(data["datasets"])

self._validate_against_schema(kind, data)
self._validate_all_expected_datasets_are_present_in_manifest(manifest_kind=kind, manifest=data)

Expand Down

0 comments on commit cca1bde

Please sign in to comment.