diff --git a/lwr/lwr_client/client.py b/lwr/lwr_client/client.py index 3aaba2d6b9906f8464b66a89a2ead0e3617531e7..4e1223c061b9d7443bfad59042e371e7220b5e0f 100644 --- a/lwr/lwr_client/client.py +++ b/lwr/lwr_client/client.py @@ -156,14 +156,14 @@ class JobClient(BaseJobClient): def put_file(self, path, input_type, name=None, contents=None, action_type='transfer'): if not name: name = os.path.basename(path) - args = {"job_id": self.job_id, "name": name, "input_type": input_type} + args = {"job_id": self.job_id, "name": name, "type": input_type} input_path = path if contents: input_path = None if action_type == 'transfer': return self._upload_file(args, contents, input_path) elif action_type == 'copy': - lwr_path = self._raw_execute('input_path', args) + lwr_path = self._raw_execute('path', args) copy(path, lwr_path) return {'path': lwr_path} @@ -221,24 +221,21 @@ class JobClient(BaseJobClient): @parseJson() def _upload_file(self, args, contents, input_path): - return self._raw_execute(self._upload_file_action(args), args, contents, input_path) - - def _upload_file_action(self, args): - return "upload_file" + return self._raw_execute("upload_file", args, contents, input_path) @parseJson() def _output_path(self, name, job_id, output_type): - return self._raw_execute("output_path", + return self._raw_execute("path", {"name": name, "job_id": self.job_id, - "output_type": output_type}) + "type": output_type}) @retry() def __raw_download_output(self, name, job_id, output_type, output_path): output_params = { "name": name, "job_id": self.job_id, - "output_type": output_type + "type": output_type } self._raw_execute("download_output", output_params, output_path=output_path) @@ -341,7 +338,7 @@ class InputCachingJobClient(JobClient): @parseJson() def _upload_file(self, args, contents, input_path): - action = self._upload_file_action(args) + action = "upload_file" if contents: input_path = None return self._raw_execute(action, args, contents, input_path) diff --git a/lwr/lwr_client/interface.py b/lwr/lwr_client/interface.py index 2bf986c28298cef31cbab7085fd4ec6097916734..540d055d27fa363fa505d61afbab0f467376993e 100644 --- a/lwr/lwr_client/interface.py +++ b/lwr/lwr_client/interface.py @@ -35,6 +35,8 @@ class LwrInteface(object): COMMAND_TO_PATH = { + "path": Template("jobs/${job_id}/files/path"), + "file_available": Template("cache/status"), "cache_required": Template("cache"), "cache_insert": Template("cache"), diff --git a/lwr/web/routes.py b/lwr/web/routes.py index a68687a5cfd5632362fba74c38b3df9c3b16fe94..37d12c80c24458098d351ea9fce24d44fb645b17 100644 --- a/lwr/web/routes.py +++ b/lwr/web/routes.py @@ -89,29 +89,31 @@ def cancel(manager, job_id): @LwrController(response_type='json') -def upload_file(manager, input_type, file_cache, job_id, name, body, cache_token=None): +def upload_file(manager, type, file_cache, job_id, name, body, cache_token=None): # Input type should be one of input, config, workdir, tool, or unstructured (see action_mapper.path_type) - path = manager.job_directory(job_id).calculate_path(name, input_type) + path = manager.job_directory(job_id).calculate_path(name, type) return _handle_upload(file_cache, path, body, cache_token=cache_token) -@LwrController(response_type='json') -def input_path(manager, input_type, job_id, name): - path = manager.job_directory(job_id).calculate_path(name, input_type) +@LwrController(path="/jobs/{job_id}/files/path", method="GET", response_type='json') +def path(manager, type, job_id, name): + if type in [path_type.OUTPUT, path_type.OUTPUT_WORKDIR]: + path = _output_path(manager, job_id, name, type) + else: + path = manager.job_directory(job_id).calculate_path(name, type) return {'path': path} @LwrController(response_type='file') -def download_output(manager, job_id, name, output_type=path_type.OUTPUT): - return _output_path(manager, job_id, name, output_type) +def download_output(manager, job_id, name, type=path_type.OUTPUT): + return _output_path(manager, job_id, name, type) -@LwrController(response_type='json') -def output_path(manager, job_id, name, output_type=path_type.OUTPUT): +def output_path(manager, job_id, name, type=path_type.OUTPUT): # output_type should be one of... # work_dir, direct # Added for non-transfer downloading. - return {"path": _output_path(manager, job_id, name, output_type)} + return {"path": _output_path(manager, job_id, name, type)} def _output_path(manager, job_id, name, output_type):