Skip to content

Commit

Permalink
Merge pull request #34 from nasa/harmony-1568
Browse files Browse the repository at this point in the history
Harmony 1568 - Add extend/extendDimensions to harmony-py and harmony-service-lib-py
  • Loading branch information
vinnyinverso authored Aug 30, 2023
2 parents df3c493 + 4495243 commit 46e8e75
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: [3.8, 3.9, '3.10']

steps:
- uses: actions/checkout@v3
Expand Down
7 changes: 4 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ autopep8 ~= 1.5
debugpy ~= 1.2
Faker ~= 8.1.3
flake8 ~= 5.0.4
ipython ~= 7.17
ipython ~= 8.10.0
jedi ~= 0.17.2
parameterized ~= 0.7
pytest ~= 6.2
pytest ~= 7.2.0
pytest-cov ~=2.11
pytest-mock ~=3.5
python-language-server ~= 0.35
responses ~=0.22.0
safety ~= 1.8
safety ~= 2.3.5
pycodestyle ~= 2.9.1
setuptools ~= 68.1.2
10 changes: 7 additions & 3 deletions example/example_message.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "../../harmony/app/schemas/data-operation/0.17.0/data-operation-v0.17.0.json",
"version": "0.17.0",
"$schema": "../../harmony/app/schemas/data-operation/0.18.0/data-operation-v0.18.0.json",
"version": "0.18.0",
"callback": "http://localhost/some-path",
"stagingLocation": "s3://example-bucket/public/some-org/some-service/some-uuid/",
"user": "jdoe",
Expand Down Expand Up @@ -64,5 +64,9 @@
"max": 12.0
}]
},
"concatenate": false
"concatenate": false,
"extendDimensions": [
"lat",
"lon"
]
}
5 changes: 4 additions & 1 deletion harmony/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ class Message(JsonObject):
concatenate: bool
True if the service should concatenate multiple input files into a single output
file and false otherwise.
extendDimensions: list
A list of dimensions to extend.
"""

def __init__(self, json_str_or_dict, decrypter=lambda x: x):
Expand Down Expand Up @@ -616,7 +618,8 @@ def __init__(self, json_str_or_dict, decrypter=lambda x: x):
'format',
'subset',
'temporal',
'concatenate'
'concatenate',
'extendDimensions'
],
list_properties={'sources': Source}
)
Expand Down
15 changes: 8 additions & 7 deletions tests/example_messages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
minimal_message = """
{
"$schema": "../../harmony/app/schemas/data-operation/0.17.0/data-operation-v0.17.0.json",
"version": "0.17.0",
"$schema": "../../harmony/app/schemas/data-operation/0.18.0/data-operation-v0.18.0.json",
"version": "0.18.0",
"callback": "http://localhost/some-path",
"stagingLocation": "s3://example-bucket/public/some-org/some-service/some-uuid/",
"user": "jdoe",
Expand All @@ -19,8 +19,8 @@

minimal_source_message = """
{
"$schema": "../../harmony/app/schemas/data-operation/0.17.0/data-operation-v0.17.0.json",
"version": "0.17.0",
"$schema": "../../harmony/app/schemas/data-operation/0.18.0/data-operation-v0.18.0.json",
"version": "0.18.0",
"callback": "http://localhost/some-path",
"stagingLocation": "s3://example-bucket/public/some-org/some-service/some-uuid/",
"user": "jdoe",
Expand All @@ -46,8 +46,8 @@

full_message = """
{
"$schema": "../../harmony/app/schemas/data-operation/0.17.0/data-operation-v0.17.0.json",
"version": "0.17.0",
"$schema": "../../harmony/app/schemas/data-operation/0.18.0/data-operation-v0.18.0.json",
"version": "0.18.0",
"callback": "http://localhost/some-path",
"stagingLocation": "s3://example-bucket/public/some-org/some-service/some-uuid/",
"user": "jdoe",
Expand Down Expand Up @@ -179,6 +179,7 @@
"max": 10.0
}]
},
"concatenate": true
"concatenate": true,
"extendDimensions": ["lat", "lon"]
}
"""
7 changes: 4 additions & 3 deletions tests/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setUp(self):
def test_when_provided_a_full_message_it_parses_it_into_objects(self):
message = Message(full_message)

self.assertEqual(message.version, '0.17.0')
self.assertEqual(message.version, '0.18.0')
self.assertEqual(message.callback, 'http://localhost/some-path')
self.assertEqual(message.stagingLocation, 's3://example-bucket/public/some-org/some-service/some-uuid/')
self.assertEqual(message.user, 'jdoe')
Expand Down Expand Up @@ -78,12 +78,13 @@ def test_when_provided_a_full_message_it_parses_it_into_objects(self):
self.assertEqual(message.subset.dimensions[1].name, 'YDim')
self.assertEqual(message.subset.dimensions[1].min, None)
self.assertEqual(message.subset.dimensions[1].max, 10)
self.assertEqual(message.extendDimensions, ["lat", "lon"])


def test_when_provided_a_minimal_message_it_parses_it_into_objects(self):
message = Message(minimal_message)

self.assertEqual(message.version, '0.17.0')
self.assertEqual(message.version, '0.18.0')
self.assertEqual(message.callback, 'http://localhost/some-path')
self.assertEqual(message.stagingLocation, 's3://example-bucket/public/some-org/some-service/some-uuid/')
self.assertEqual(message.user, 'jdoe')
Expand All @@ -103,7 +104,7 @@ def test_when_provided_a_minimal_message_it_parses_it_into_objects(self):
def test_when_provided_a_message_with_minimal_source_it_parses_it_into_objects(self):
message = Message(minimal_source_message)

self.assertEqual(message.version, '0.17.0')
self.assertEqual(message.version, '0.18.0')
self.assertEqual(message.callback, 'http://localhost/some-path')
self.assertEqual(message.user, 'jdoe')
self.assertEqual(message.accessToken, 'ABCD1234567890')
Expand Down

0 comments on commit 46e8e75

Please sign in to comment.