Skip to content

Commit f2553d9

Browse files
authored
Merge pull request #1 from ecmwf-projects/develop
Release 0.7.0
2 parents c5c28e1 + 7706a83 commit f2553d9

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

polytope/api/RequestManager.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,19 @@ def retrieve(
329329
if not inline_request:
330330
self._logger.info("Reading request file...")
331331
request = os.path.expanduser(request)
332-
with open(request) as request_file_handler:
333-
request = yaml.safe_load(request_file_handler)
332+
# If we receive a file, pass it on as a string
333+
with open(request, "r") as request_file_handler:
334+
request = request_file_handler.read()
334335
else:
335-
request = copy.deepcopy(request)
336+
# If we receive a Python dictionary, encode it as yaml
337+
# TODO: we don't know what the eventual data source requires,
338+
# encoding to YAML is the most flexible approach for now, but
339+
# this needs a more robust solution.
340+
if isinstance(request, dict):
341+
request = yaml.safe_dump(request)
342+
# else try to convert plainly to string
343+
else:
344+
request = str(request)
336345
if not isinstance(request, list):
337346
user_requests = [request]
338347
else:

polytope/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.6.3"
1+
__version__ = "0.7.0"

tests/unit/test_polytope_client.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def test_session_config():
4747

4848

4949
def test_session_config_port_in_address():
50-
5150
a = "aaa.com:123"
5251
p = 200
5352
c = Client(address=a, port=p, config_path=ValueStorage.config_path)
@@ -56,7 +55,6 @@ def test_session_config_port_in_address():
5655

5756

5857
def test_session_config_http():
59-
6058
a = "https://aaa.com"
6159
c = Client(address=a, config_path=ValueStorage.config_path)
6260
url = c.config.get_url("api_root")
@@ -66,7 +64,6 @@ def test_session_config_http():
6664

6765

6866
def test_session_config_address_path():
69-
7067
a = "aaa.com:32/abc"
7168
c = Client(address=a, config_path=ValueStorage.config_path)
7269
url = c.config.get_url("api_root")
@@ -76,23 +73,20 @@ def test_session_config_address_path():
7673

7774

7875
def test_session_config_address_path_with_port():
79-
8076
a = "aaa.com/abc"
8177
c = Client(address=a, port=32, config_path=ValueStorage.config_path)
8278
url = c.config.get_url("api_root")
8379
assert url.startswith("https://aaa.com:32/abc")
8480

8581

8682
def test_session_config_invalid_scheme():
87-
8883
a = "ftp://aaa.com/abc"
8984
c = Client(address=a, config_path=ValueStorage.config_path)
9085
with pytest.raises(ValueError):
9186
c.config.get_url("api_root")
9287

9388

9489
def test_session_config_invalid_host():
95-
9690
a = "ftp:aaa.com/abc"
9791
c = Client(address=a, config_path=ValueStorage.config_path)
9892
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)