From 3c98ca1531cdab6b56d9dac8278b831624f6f3d9 Mon Sep 17 00:00:00 2001 From: Eddy Date: Fri, 14 Aug 2020 12:42:56 +0100 Subject: Mimic CDS UI requests --- cdsapi/api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cdsapi/api.py b/cdsapi/api.py index 2befa13..029c1c7 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -332,10 +332,16 @@ class Client(object): result.download(target) return result - def service(self, name, *args, **kwargs): + def service(self, name, *args, mimic_ui=False, **kwargs): self.delete = False # Don't delete results name = '/'.join(name.split('.')) request = dict(args=args, kwargs=kwargs) + # To mimic the CDS ui the args must included directly at the top level of the request + # This is applicable to preloading application workflows + if mimic_ui: + request.update(request['args'][0]) + del request['args'] + if self.metadata: request['_cds_metadata'] = self.metadata request = toJSON(request) -- cgit v1.2.3 From 7576e1b17c78270211f9524166e4539245efc621 Mon Sep 17 00:00:00 2001 From: Eddy Date: Tue, 18 Aug 2020 17:51:02 +0100 Subject: Directly populate the request with kwargs --- cdsapi/api.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cdsapi/api.py b/cdsapi/api.py index 029c1c7..5726489 100644 --- a/cdsapi/api.py +++ b/cdsapi/api.py @@ -335,12 +335,11 @@ class Client(object): def service(self, name, *args, mimic_ui=False, **kwargs): self.delete = False # Don't delete results name = '/'.join(name.split('.')) - request = dict(args=args, kwargs=kwargs) - # To mimic the CDS ui the args must included directly at the top level of the request - # This is applicable to preloading application workflows + # To mimic the CDS ui the request should be populated directly with the kwargs if mimic_ui: - request.update(request['args'][0]) - del request['args'] + request = kwargs + else: + request = dict(args=args, kwargs=kwargs) if self.metadata: request['_cds_metadata'] = self.metadata -- cgit v1.2.3