From 4cbca6b4b0753830a334f703d407510056487ca0 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 11 Jun 2023 08:29:13 -0400 Subject: [PATCH 01/36] only work when the jupyter is visited from localhost --- pygeoweaver/server.py | 4 ++-- pyproject.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pygeoweaver/server.py b/pygeoweaver/server.py index cdb1fd1..dc9fa55 100644 --- a/pygeoweaver/server.py +++ b/pygeoweaver/server.py @@ -1,4 +1,5 @@ import os +import socket import subprocess import webbrowser from pygeoweaver.constants import GEOWEAVER_DEFAULT_ENDPOINT_URL @@ -51,14 +52,13 @@ def stop(): shell=True, ) - def show(geoweaver_url=GEOWEAVER_DEFAULT_ENDPOINT_URL): download_geoweaver_jar() # check if geoweaver is initialized check_java() if check_ipython(): logger.info("enter ipython block") from IPython.display import IFrame - + logger.warning("This only works when the Jupyter is visited from localhost!") return IFrame(src=geoweaver_url, width="100%", height="500px") else: logger.info("enter self opening block") diff --git a/pyproject.toml b/pyproject.toml index e9af0ee..205377b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pygeoweaver" -version = "0.6.16" +version = "0.6.17" authors = [ { name="Geoweaver team", email="geoweaver.app@gmail.com" }, ] @@ -22,7 +22,7 @@ classifiers = [ [tool.poetry] name = "pygeoweaver" -version = "0.6.16" +version = "0.6.17" description = "This is a wrapper package of the Geoweaver app." authors = ["Geoweaver team "] readme = "README.md" From d52dd35fd38db5a512f1d3425457dc8e96f0ac83 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 13:35:37 -0400 Subject: [PATCH 02/36] changes to sc_detail --- pygeoweaver/sc_detail.py | 16 +++++++++++++ pygeoweaver/sc_find.py | 49 ++++++++++++++++++++++++++++++++++++++++ pygeoweaver/sc_list.py | 22 +++++++++++++++++- pygeoweaver/server.py | 1 + 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 pygeoweaver/sc_find.py diff --git a/pygeoweaver/sc_detail.py b/pygeoweaver/sc_detail.py index 4bbe753..6c40cdc 100644 --- a/pygeoweaver/sc_detail.py +++ b/pygeoweaver/sc_detail.py @@ -3,6 +3,10 @@ """ import subprocess + +import requests +from . import constants + from pygeoweaver.utils import ( download_geoweaver_jar, get_geoweaver_jar_path, @@ -57,3 +61,15 @@ def detail_host(host_id): ], cwd=f"{get_root_dir()}/", ) + + +def get_code_for_process(process_id): + r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", + data={'type': 'process', 'id': process_id}).json() + code = r['code'] + + decoded_string = code + + return decoded_string + + diff --git a/pygeoweaver/sc_find.py b/pygeoweaver/sc_find.py new file mode 100644 index 0000000..6a25759 --- /dev/null +++ b/pygeoweaver/sc_find.py @@ -0,0 +1,49 @@ +import json + +import requests +import subprocess +from . import constants +from pygeoweaver.utils import ( + download_geoweaver_jar, + get_geoweaver_jar_path, + get_java_bin_path, + get_root_dir, check_ipython, +) +import pandas as pd + + +def get_process_by_name(process_name): + response = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={'type': 'process'}) + process_list = response.json() + + matching_processes = [] + + for process in process_list: + if process['name'] == process_name: + matching_processes.append(process) + pd.DataFrame(matching_processes) + + +def get_process_by_id(process_id): + response = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={'type': 'process'}) + process_list = response.json() + + matching_processes = [] + + for process in process_list: + if process['id'] == process_id: + matching_processes.append(process) + pd.DataFrame(matching_processes) + + +def get_process_by_language(language): + response = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={'type': 'process'}) + process_list = response.json() + + matching_processes = [] + + for process in process_list: + if process['lang'] == language: + matching_processes.append(process) + pd.DataFrame(matching_processes) + diff --git a/pygeoweaver/sc_list.py b/pygeoweaver/sc_list.py index ce1915f..6d37d41 100644 --- a/pygeoweaver/sc_list.py +++ b/pygeoweaver/sc_list.py @@ -1,10 +1,15 @@ +import json + +import requests import subprocess +from . import constants from pygeoweaver.utils import ( download_geoweaver_jar, get_geoweaver_jar_path, get_java_bin_path, - get_root_dir, + get_root_dir, check_ipython, ) +import pandas as pd def list_hosts(): @@ -24,6 +29,21 @@ def list_processes(): ) +def list_processes_in_workflow(workflow_id): + download_geoweaver_jar() + payload = { + 'id': workflow_id, + 'type': 'workflow' + } + r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", data=payload) + nodes = json.loads(r.json()['nodes']) + result = [{'title': item['title'], 'id': item['id']} for item in nodes] + + if check_ipython(): + return pd.DataFrame(result) + return result + + def list_workflows(): download_geoweaver_jar() subprocess.run( diff --git a/pygeoweaver/server.py b/pygeoweaver/server.py index dc9fa55..6356389 100644 --- a/pygeoweaver/server.py +++ b/pygeoweaver/server.py @@ -52,6 +52,7 @@ def stop(): shell=True, ) + def show(geoweaver_url=GEOWEAVER_DEFAULT_ENDPOINT_URL): download_geoweaver_jar() # check if geoweaver is initialized check_java() From 2552b7a73074cadabb49682235ad62b7361b571f Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 14:27:35 -0400 Subject: [PATCH 03/36] added sync function and directional sync --- pygeoweaver/sc_detail.py | 2 -- pygeoweaver/sc_sync.py | 41 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/pygeoweaver/sc_detail.py b/pygeoweaver/sc_detail.py index 6c40cdc..254478d 100644 --- a/pygeoweaver/sc_detail.py +++ b/pygeoweaver/sc_detail.py @@ -67,9 +67,7 @@ def get_code_for_process(process_id): r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", data={'type': 'process', 'id': process_id}).json() code = r['code'] - decoded_string = code - return decoded_string diff --git a/pygeoweaver/sc_sync.py b/pygeoweaver/sc_sync.py index 9a3bfaf..f19a312 100644 --- a/pygeoweaver/sc_sync.py +++ b/pygeoweaver/sc_sync.py @@ -4,6 +4,7 @@ import requests import typing +from enum import Enum from . import constants from pygeoweaver.utils import ( @@ -15,6 +16,44 @@ ) +class Direction(str, Enum): + DOWNLOAD = "DOWNLOAD" + UPLOAD = "UPLOAD" + + +def sync(process_id: str, sync_to_path: typing.Union[str, os.PathLike], direction: Direction): + if direction == Direction.DOWNLOAD: + if not sync_to_path: + raise Exception("Sync path not found.") + r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", + data={'type': 'process', 'id': process_id}).json() + code = r['code'] + decoded_string = code + file_name = r['name'] + ext = None + if r['lang'] == "python": + ext = ".py" + elif r['lang'] == "bash": + ext = ".sh" + else: + raise Exception("Unknown file format.") + with open(os.path.join(sync_to_path, file_name + ext), 'w') as file: + file.write(decoded_string) + if direction == Direction.UPLOAD: + if not sync_to_path: + raise Exception("Sync path not found.") + process_prev_state = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", + data={'type': 'process', 'id': process_id}).json() + f = open(sync_to_path, 'r') + f_content = f.read() + f.close() + process_prev_state['code'] = f_content + requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/edit/process", + data=json.dumps(process_prev_state), headers={'Content-Type': 'application/json'}) + else: + raise Exception("Please specify the direction to sync. Choices - [UPLOAD, DOWNLOAD]") + + def sync_workflow(workflow_id: str, sync_to_path: typing.Union[str, os.PathLike]): download_geoweaver_jar() # download workflow @@ -29,7 +68,7 @@ def sync_workflow(workflow_id: str, sync_to_path: typing.Union[str, os.PathLike] os.makedirs(tmp_dir) # unzip the workflow with zipfile.ZipFile( - os.path.join(home_dir, "gw-workspace", "temp", filename) + os.path.join(home_dir, "gw-workspace", "temp", filename) ) as ref: ref.extractall(os.path.join(home_dir, "tmp")) # check if target workflow path and the unzipped workflow match From 07e848da2c723eb83eddf1b1a90e7146f8b5470e Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 14:45:56 -0400 Subject: [PATCH 04/36] added find functions to interface --- pygeoweaver/sc_find.py | 9 --------- pygeoweaver/sc_interface.py | 1 + 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/pygeoweaver/sc_find.py b/pygeoweaver/sc_find.py index 6a25759..15eddf0 100644 --- a/pygeoweaver/sc_find.py +++ b/pygeoweaver/sc_find.py @@ -1,14 +1,5 @@ -import json - import requests -import subprocess from . import constants -from pygeoweaver.utils import ( - download_geoweaver_jar, - get_geoweaver_jar_path, - get_java_bin_path, - get_root_dir, check_ipython, -) import pandas as pd diff --git a/pygeoweaver/sc_interface.py b/pygeoweaver/sc_interface.py index 07bdc4b..0dbe5c0 100644 --- a/pygeoweaver/sc_interface.py +++ b/pygeoweaver/sc_interface.py @@ -13,3 +13,4 @@ from pygeoweaver.sc_help import * from pygeoweaver.sc_create import * from pygeoweaver.sc_sync import * +from pygeoweaver.sc_find import * \ No newline at end of file From 568de53d4fa875851e07f38bb7b7c02bd284077e Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 14:46:03 -0400 Subject: [PATCH 05/36] cleanup --- pygeoweaver/sc_interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygeoweaver/sc_interface.py b/pygeoweaver/sc_interface.py index 0dbe5c0..e17b569 100644 --- a/pygeoweaver/sc_interface.py +++ b/pygeoweaver/sc_interface.py @@ -13,4 +13,4 @@ from pygeoweaver.sc_help import * from pygeoweaver.sc_create import * from pygeoweaver.sc_sync import * -from pygeoweaver.sc_find import * \ No newline at end of file +from pygeoweaver.sc_find import * From 27a5ac60aa03914ec54629cc3f785f1ef0ef222e Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 15:05:36 -0400 Subject: [PATCH 06/36] print code instead of return --- pygeoweaver/sc_detail.py | 2 +- pygeoweaver/sc_list.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygeoweaver/sc_detail.py b/pygeoweaver/sc_detail.py index 254478d..ab42c70 100644 --- a/pygeoweaver/sc_detail.py +++ b/pygeoweaver/sc_detail.py @@ -68,6 +68,6 @@ def get_code_for_process(process_id): data={'type': 'process', 'id': process_id}).json() code = r['code'] decoded_string = code - return decoded_string + print(decoded_string) diff --git a/pygeoweaver/sc_list.py b/pygeoweaver/sc_list.py index 6d37d41..1218930 100644 --- a/pygeoweaver/sc_list.py +++ b/pygeoweaver/sc_list.py @@ -37,7 +37,7 @@ def list_processes_in_workflow(workflow_id): } r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", data=payload) nodes = json.loads(r.json()['nodes']) - result = [{'title': item['title'], 'id': item['id']} for item in nodes] + result = [{'title': item['title'], 'id': item['id'].split('.')[0]} for item in nodes] if check_ipython(): return pd.DataFrame(result) From 9f980d09c7e7cd88c50fa42ce9bef723b972d068 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 15:12:33 -0400 Subject: [PATCH 07/36] added debug log --- pygeoweaver/sc_sync.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygeoweaver/sc_sync.py b/pygeoweaver/sc_sync.py index f19a312..b80e240 100644 --- a/pygeoweaver/sc_sync.py +++ b/pygeoweaver/sc_sync.py @@ -22,6 +22,7 @@ class Direction(str, Enum): def sync(process_id: str, sync_to_path: typing.Union[str, os.PathLike], direction: Direction): + print(f'Proceeding with {direction}\n') if direction == Direction.DOWNLOAD: if not sync_to_path: raise Exception("Sync path not found.") From 7b66bb6c92df2f378532d100d8222d8db9158901 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 15:19:21 -0400 Subject: [PATCH 08/36] cleanup changes to Enum --- pygeoweaver/sc_sync.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pygeoweaver/sc_sync.py b/pygeoweaver/sc_sync.py index b80e240..bb1153a 100644 --- a/pygeoweaver/sc_sync.py +++ b/pygeoweaver/sc_sync.py @@ -4,26 +4,17 @@ import requests import typing -from enum import Enum from . import constants from pygeoweaver.utils import ( download_geoweaver_jar, - get_geoweaver_jar_path, - get_java_bin_path, - get_root_dir, copy_files, ) -class Direction(str, Enum): - DOWNLOAD = "DOWNLOAD" - UPLOAD = "UPLOAD" - - -def sync(process_id: str, sync_to_path: typing.Union[str, os.PathLike], direction: Direction): +def sync(process_id: str, sync_to_path: typing.Union[str, os.PathLike], direction: str): print(f'Proceeding with {direction}\n') - if direction == Direction.DOWNLOAD: + if direction == "download": if not sync_to_path: raise Exception("Sync path not found.") r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", @@ -40,7 +31,7 @@ def sync(process_id: str, sync_to_path: typing.Union[str, os.PathLike], directio raise Exception("Unknown file format.") with open(os.path.join(sync_to_path, file_name + ext), 'w') as file: file.write(decoded_string) - if direction == Direction.UPLOAD: + if direction == "upload": if not sync_to_path: raise Exception("Sync path not found.") process_prev_state = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", From 29da72d4a88f420cd93f90bc979c74eda0423fb1 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 15:21:28 -0400 Subject: [PATCH 09/36] cleanup changes to Enum --- pygeoweaver/sc_sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygeoweaver/sc_sync.py b/pygeoweaver/sc_sync.py index bb1153a..f01e139 100644 --- a/pygeoweaver/sc_sync.py +++ b/pygeoweaver/sc_sync.py @@ -31,7 +31,7 @@ def sync(process_id: str, sync_to_path: typing.Union[str, os.PathLike], directio raise Exception("Unknown file format.") with open(os.path.join(sync_to_path, file_name + ext), 'w') as file: file.write(decoded_string) - if direction == "upload": + elif direction == "upload": if not sync_to_path: raise Exception("Sync path not found.") process_prev_state = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", From 9f69c5870bd4925503da6d5df762b9d7c16f2557 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 15:23:05 -0400 Subject: [PATCH 10/36] added logger --- pygeoweaver/sc_sync.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygeoweaver/sc_sync.py b/pygeoweaver/sc_sync.py index f01e139..87b4195 100644 --- a/pygeoweaver/sc_sync.py +++ b/pygeoweaver/sc_sync.py @@ -31,6 +31,7 @@ def sync(process_id: str, sync_to_path: typing.Union[str, os.PathLike], directio raise Exception("Unknown file format.") with open(os.path.join(sync_to_path, file_name + ext), 'w') as file: file.write(decoded_string) + print(f'Wrote file {file_name + ext} to {sync_to_path}') elif direction == "upload": if not sync_to_path: raise Exception("Sync path not found.") From ef9ad008b7a7457644d0c6058c057d4e6228519a Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 15:50:12 -0400 Subject: [PATCH 11/36] changes to workflow history --- pygeoweaver/sc_history.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygeoweaver/sc_history.py b/pygeoweaver/sc_history.py index b7e93cc..12eb043 100644 --- a/pygeoweaver/sc_history.py +++ b/pygeoweaver/sc_history.py @@ -38,7 +38,9 @@ def get_process_history(process_id): f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/logs", data={"type": "process", "id": process_id}, ).json() - return pd.DataFrame(r) + df = pd.DataFrame(r) + df['history_begin_time'] = pd.to_datetime(df['history_begin_time'], unit='ms') + df['history_end_time'] = pd.to_datetime(df['history_end_time'], unit='ms') except Exception as e: subprocess.run( f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} process-history {process_id}", From 6972070dc7ba3ad7177a4677f2d1468a777b27b1 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 15:52:09 -0400 Subject: [PATCH 12/36] changes to workflow history --- pygeoweaver/sc_history.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygeoweaver/sc_history.py b/pygeoweaver/sc_history.py index 12eb043..6376cce 100644 --- a/pygeoweaver/sc_history.py +++ b/pygeoweaver/sc_history.py @@ -41,6 +41,7 @@ def get_process_history(process_id): df = pd.DataFrame(r) df['history_begin_time'] = pd.to_datetime(df['history_begin_time'], unit='ms') df['history_end_time'] = pd.to_datetime(df['history_end_time'], unit='ms') + return df except Exception as e: subprocess.run( f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} process-history {process_id}", From 37afbf2b3fbee892dd78e97363da44e28046e0c7 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 15:54:39 -0400 Subject: [PATCH 13/36] apply changes to workflow for execution time --- pygeoweaver/sc_history.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pygeoweaver/sc_history.py b/pygeoweaver/sc_history.py index 6376cce..383107a 100644 --- a/pygeoweaver/sc_history.py +++ b/pygeoweaver/sc_history.py @@ -62,7 +62,10 @@ def get_workflow_history(workflow_id): f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/logs", data={"type": "workflow", "id": workflow_id}, ).json() - return pd.DataFrame(r) + df = pd.DataFrame(r) + df['history_begin_time'] = pd.to_datetime(df['history_begin_time'], unit='ms') + df['history_end_time'] = pd.to_datetime(df['history_end_time'], unit='ms') + return df except Exception as e: subprocess.run( f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} workflow-history {workflow_id}", From 2bd5e9c5cccba69cb0d05626607545a5b7625413 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 16:11:54 -0400 Subject: [PATCH 14/36] update code and run process --- pygeoweaver/sc_run.py | 76 +++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 50 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 918c86d..d98abe1 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -15,12 +15,12 @@ def run_process( - *, - process_id: str, - host_id: str, - password: str = None, - environment: str = None, - sync_path: os.PathLike = None, + *, + process_id: str, + host_id: str, + password: str = None, + environment: str = None, + sync_path: os.PathLike = None, ): """ Run a process @@ -33,43 +33,19 @@ def run_process( if password is None: # prompt to ask for password password = getpass.getpass(f"Enter password for host - {host_id}: ") - + if sync_path: - ext, matching_dict = None, None - process_file = os.path.exists(os.path.join(sync_path, "code", "process.json")) - if not process_file: - print("process file does not exists, please check the path") - return - p_file = json.loads( - open(os.path.join(sync_path, "code", "process.json"), "r").read() - ) - for item in p_file: - if item.get("id") == process_id: - matching_dict = item - break - if not matching_dict: - print("Could not find the file, please check the path") - return - if matching_dict["lang"] == "python": - ext = ".py" - if matching_dict["lang"] == "bash": - ext = ".bash" - if not ext: - print("Invalid file format.") - source_filename = matching_dict["name"] + ext - source_file_exists = os.path.exists( - os.path.join(sync_path, "code", source_filename) - ) - if source_file_exists: - f = open(os.path.join(sync_path, "code", source_filename), "r").read() - matching_dict["code"] = f - requests.post( - f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/edit/process", - data=json.dumps(matching_dict), - headers={"Content-Type": "application/json"}, - ) - else: - print("File does not exists") + if not os.path.exists(sync_path): + print('The specified path does nto exists') + f = open(sync_path, "r") + context = f.read() + f.close() + details = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", + data={'type': 'process', 'id': process_id}).json() + details['code'] = context + requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/edit/process", + data=json.dumps(details), headers={'Content-Type': 'application/json'}) + download_geoweaver_jar() subprocess.run( [ @@ -88,14 +64,14 @@ def run_process( def run_workflow( - *, - workflow_id: str, - workflow_folder_path: str = None, - workflow_zip_file_path: str = None, - environment_list: str = None, - host_list: str = None, - password_list: str = None, - sync_path: os.PathLike = None, + *, + workflow_id: str, + workflow_folder_path: str = None, + workflow_zip_file_path: str = None, + environment_list: str = None, + host_list: str = None, + password_list: str = None, + sync_path: os.PathLike = None, ): """ Usage:
run workflow [-d=] From d2db4c078a8a28f893f35477077d6ac21fa7c251 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 16:19:31 -0400 Subject: [PATCH 15/36] added logger --- pygeoweaver/sc_run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index d98abe1..8ce22a2 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -37,6 +37,7 @@ def run_process( if sync_path: if not os.path.exists(sync_path): print('The specified path does nto exists') + print('Updating code on workflow with the given file path.\n') f = open(sync_path, "r") context = f.read() f.close() From aff4c63cc5117a9895b80899a233e1873fed4509 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 16:42:46 -0400 Subject: [PATCH 16/36] added logger --- pygeoweaver/sc_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygeoweaver/sc_export.py b/pygeoweaver/sc_export.py index ea0a4d7..93a9c58 100644 --- a/pygeoweaver/sc_export.py +++ b/pygeoweaver/sc_export.py @@ -7,7 +7,7 @@ ) -def export_workflow(workflow_id, mode, target_file_path): +def export_workflow(workflow_id, mode=4, target_file_path=None): """ Usage:
export workflow [--mode=] From 7bee056b742d2fcb6fc987e1c03cb94ef278380e Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 16:48:40 -0400 Subject: [PATCH 17/36] extract zipped file --- pygeoweaver/sc_export.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pygeoweaver/sc_export.py b/pygeoweaver/sc_export.py index 93a9c58..e1ff010 100644 --- a/pygeoweaver/sc_export.py +++ b/pygeoweaver/sc_export.py @@ -1,3 +1,5 @@ +import os.path +import zipfile import subprocess from pygeoweaver.utils import ( download_geoweaver_jar, @@ -7,7 +9,7 @@ ) -def export_workflow(workflow_id, mode=4, target_file_path=None): +def export_workflow(workflow_id, mode=4, target_file_path=None, unzip=False): """ Usage:
export workflow [--mode=] @@ -37,3 +39,8 @@ def export_workflow(workflow_id, mode=4, target_file_path=None): ], cwd=f"{get_root_dir()}/", ) + if unzip: + with zipfile.ZipFile(target_file_path, 'r') as zip_ref: + zip_ref.extractall(os.path.dirname(target_file_path)) + + From e363cd5fd3a94d0478fca80ccf11fb8b1055faed Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 16:56:20 -0400 Subject: [PATCH 18/36] extract zipped file --- pygeoweaver/sc_export.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygeoweaver/sc_export.py b/pygeoweaver/sc_export.py index e1ff010..6629b52 100644 --- a/pygeoweaver/sc_export.py +++ b/pygeoweaver/sc_export.py @@ -9,7 +9,7 @@ ) -def export_workflow(workflow_id, mode=4, target_file_path=None, unzip=False): +def export_workflow(workflow_id, mode=4, target_file_path=None, unzip=False, unzip_directory_name=None): """ Usage:
export workflow [--mode=] @@ -40,7 +40,9 @@ def export_workflow(workflow_id, mode=4, target_file_path=None, unzip=False): cwd=f"{get_root_dir()}/", ) if unzip: + if not unzip_directory_name: + raise Exception("Please provide unzip directory name") with zipfile.ZipFile(target_file_path, 'r') as zip_ref: - zip_ref.extractall(os.path.dirname(target_file_path)) + zip_ref.extractall(os.path.join(os.path.dirname(target_file_path), unzip_directory_name)) From f867ed5250d0d5e0eca8a460b76c99ec1dce5df1 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:19:30 -0400 Subject: [PATCH 19/36] changes to workflow --- pygeoweaver/sc_run.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 8ce22a2..94ac0d0 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -118,10 +118,13 @@ def run_workflow( "run", "workflow", workflow_id, + "-h", + host_list, + "-p", + password_list ] if environment_list: command.extend(["-e", environment_list]) - command.extend(["-h", host_list, "-p", ",".join(password_list)]) subprocess.run(command, cwd=f"{get_root_dir()}/") if workflow_folder_path and not workflow_zip_file_path: @@ -133,12 +136,15 @@ def run_workflow( "run", "workflow", workflow_id, + "-d", + workflow_folder_path, + "-h", + host_list, + "-p", + password_list ] if environment_list: command.extend(["-e", environment_list]) - command.extend( - ["-d", workflow_folder_path, "-h", host_list, "-p", password_list] - ) subprocess.run(command, cwd=f"{get_root_dir()}/") if not workflow_folder_path and workflow_zip_file_path: @@ -149,10 +155,13 @@ def run_workflow( "run", "workflow", workflow_id, + "-f", + workflow_zip_file_path, + "-h", + host_list, + "-p", + password_list ] if environment_list: command.extend(["-e", environment_list]) - command.extend( - ["-f", workflow_zip_file_path, "-h", host_list, "-p", password_list] - ) subprocess.run(command, cwd=f"{get_root_dir()}/") From 475f89131b9c35e927c851564e16ef48918613fd Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:26:19 -0400 Subject: [PATCH 20/36] changes to workflow --- pygeoweaver/sc_run.py | 52 +++++-------------------------------------- 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 94ac0d0..674bb9a 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -111,57 +111,17 @@ def run_workflow( ) if workflow_id and not workflow_folder_path and not workflow_zip_file_path: - command = [ - get_java_bin_path(), - "-jar", - get_geoweaver_jar_path(), - "run", - "workflow", - workflow_id, - "-h", - host_list, - "-p", - password_list - ] - if environment_list: - command.extend(["-e", environment_list]) + command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", + workflow_id, "-h", host_list, "-p", password_list] subprocess.run(command, cwd=f"{get_root_dir()}/") if workflow_folder_path and not workflow_zip_file_path: # command to run workflow from folder - command = [ - get_java_bin_path(), - "-jar", - get_geoweaver_jar_path(), - "run", - "workflow", - workflow_id, - "-d", - workflow_folder_path, - "-h", - host_list, - "-p", - password_list - ] - if environment_list: - command.extend(["-e", environment_list]) + command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, + "-d", workflow_folder_path, "-h", host_list, "-p", password_list] subprocess.run(command, cwd=f"{get_root_dir()}/") if not workflow_folder_path and workflow_zip_file_path: - command = [ - get_java_bin_path(), - "-jar", - get_geoweaver_jar_path(), - "run", - "workflow", - workflow_id, - "-f", - workflow_zip_file_path, - "-h", - host_list, - "-p", - password_list - ] - if environment_list: - command.extend(["-e", environment_list]) + command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, "-f", + workflow_zip_file_path, "-h", host_list, "-p", password_list] subprocess.run(command, cwd=f"{get_root_dir()}/") From 1f201bcb5198f6c76160a2ae485b9a143cc165ce Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:31:34 -0400 Subject: [PATCH 21/36] added debugger --- pygeoweaver/sc_run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 674bb9a..1b589e8 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -111,6 +111,7 @@ def run_workflow( ) if workflow_id and not workflow_folder_path and not workflow_zip_file_path: + print(f"Using host: {host_list}") command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, "-h", host_list, "-p", password_list] subprocess.run(command, cwd=f"{get_root_dir()}/") From eefcda234f633fc4ee001a96da7b856010f238dd Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:34:27 -0400 Subject: [PATCH 22/36] added debugger --- pygeoweaver/sc_run.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 1b589e8..340ec3e 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -111,12 +111,14 @@ def run_workflow( ) if workflow_id and not workflow_folder_path and not workflow_zip_file_path: - print(f"Using host: {host_list}") command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, "-h", host_list, "-p", password_list] subprocess.run(command, cwd=f"{get_root_dir()}/") if workflow_folder_path and not workflow_zip_file_path: + print('Running command using :', + [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, + "-d", workflow_folder_path, "-h", host_list]) # command to run workflow from folder command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, "-d", workflow_folder_path, "-h", host_list, "-p", password_list] From 2d4ff62bcf5f771d1d1cad83fae0d85c1a025d31 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:38:11 -0400 Subject: [PATCH 23/36] optimize run workflow --- pygeoweaver/sc_run.py | 53 +++++++++++-------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 340ec3e..bf82a6d 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -65,7 +65,6 @@ def run_process( def run_workflow( - *, workflow_id: str, workflow_folder_path: str = None, workflow_zip_file_path: str = None, @@ -74,24 +73,10 @@ def run_workflow( password_list: str = None, sync_path: os.PathLike = None, ): - """ - Usage:
run workflow [-d=] - [-f=] [-e=]... - [-h=]... [-p=]... - - workflow id to run - -d, --workflow-folder-path= - geoweaver workflow folder path - -e, --environments= environments to run on. List of environment ids with comma as separator - -f, --workflow-zip-file-path= - workflow package or path to workflow zip to run - -h, --hosts= hosts to run on. list of host ids with comma as separator. - -p, --passwords= passwords to the target hosts. list of passwords with comma as separator. - """ download_geoweaver_jar() if password_list is None: - # prompt to ask for password + # Prompt to ask for password password_list = [] for host in host_list.split(","): password = getpass.getpass(f"Enter password for host - {host}: ") @@ -101,30 +86,18 @@ def run_workflow( if sync_path: from . import sync_workflow - sync_workflow(workflow_id=workflow_id, sync_to_path=sync_path) if not workflow_id and not workflow_folder_path and not workflow_zip_file_path: - raise RuntimeError( - "Please provide at least one of the three options: workflow id, " - "folder path or zip path" - ) - - if workflow_id and not workflow_folder_path and not workflow_zip_file_path: - command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", - workflow_id, "-h", host_list, "-p", password_list] - subprocess.run(command, cwd=f"{get_root_dir()}/") - - if workflow_folder_path and not workflow_zip_file_path: - print('Running command using :', - [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, - "-d", workflow_folder_path, "-h", host_list]) - # command to run workflow from folder - command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, - "-d", workflow_folder_path, "-h", host_list, "-p", password_list] - subprocess.run(command, cwd=f"{get_root_dir()}/") - - if not workflow_folder_path and workflow_zip_file_path: - command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, "-f", - workflow_zip_file_path, "-h", host_list, "-p", password_list] - subprocess.run(command, cwd=f"{get_root_dir()}/") + raise RuntimeError("Please provide at least one of the three options: workflow id, folder path, or zip path") + + command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id] + if workflow_folder_path: + command.extend(["-d", workflow_folder_path]) + if workflow_zip_file_path: + command.extend(["-f", workflow_zip_file_path]) + if host_list: + command.extend(["-h"] + host_list.split(",")) + if password_list: + command.extend(["-p"] + password_list.split(",")) + subprocess.run(command, cwd=get_root_dir()) From 7014d36584898a8d9ab4c4c0de374558c156693f Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:41:47 -0400 Subject: [PATCH 24/36] optimize run workflow --- pygeoweaver/sc_run.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index bf82a6d..7c6039d 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -76,13 +76,7 @@ def run_workflow( download_geoweaver_jar() if password_list is None: - # Prompt to ask for password - password_list = [] - for host in host_list.split(","): - password = getpass.getpass(f"Enter password for host - {host}: ") - password_list.append(password) - elif len(password_list.split(",")) != len(host_list.split(",")): - raise RuntimeError("The password list length doesn't match host list") + password_list = getpass.getpass(f"Enter password for host: ") if sync_path: from . import sync_workflow From 41822e674c1bc7f0bb653c8d08436ba1a419542d Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:43:37 -0400 Subject: [PATCH 25/36] optimize run workflow --- pygeoweaver/sc_run.py | 48 ++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 7c6039d..1597c1b 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -65,6 +65,7 @@ def run_process( def run_workflow( + *, workflow_id: str, workflow_folder_path: str = None, workflow_zip_file_path: str = None, @@ -73,6 +74,20 @@ def run_workflow( password_list: str = None, sync_path: os.PathLike = None, ): + """ + Usage:
run workflow [-d=] + [-f=] [-e=]... + [-h=]... [-p=]... + + workflow id to run + -d, --workflow-folder-path= + geoweaver workflow folder path + -e, --environments= environments to run on. List of environment ids with comma as separator + -f, --workflow-zip-file-path= + workflow package or path to workflow zip to run + -h, --hosts= hosts to run on. list of host ids with comma as separator. + -p, --passwords= passwords to the target hosts. list of passwords with comma as separator. + """ download_geoweaver_jar() if password_list is None: @@ -80,18 +95,27 @@ def run_workflow( if sync_path: from . import sync_workflow + sync_workflow(workflow_id=workflow_id, sync_to_path=sync_path) if not workflow_id and not workflow_folder_path and not workflow_zip_file_path: - raise RuntimeError("Please provide at least one of the three options: workflow id, folder path, or zip path") - - command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id] - if workflow_folder_path: - command.extend(["-d", workflow_folder_path]) - if workflow_zip_file_path: - command.extend(["-f", workflow_zip_file_path]) - if host_list: - command.extend(["-h"] + host_list.split(",")) - if password_list: - command.extend(["-p"] + password_list.split(",")) - subprocess.run(command, cwd=get_root_dir()) + raise RuntimeError( + "Please provide at least one of the three options: workflow id, " + "folder path or zip path" + ) + + if workflow_id and not workflow_folder_path and not workflow_zip_file_path: + command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", + workflow_id, "-h", host_list, "-p", password_list] + subprocess.run(command, cwd=f"{get_root_dir()}/") + + if workflow_folder_path and not workflow_zip_file_path: + # command to run workflow from folder + command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, + "-d", workflow_folder_path, "-h", host_list, "-p", password_list] + subprocess.run(command, cwd=f"{get_root_dir()}/") + + if not workflow_folder_path and workflow_zip_file_path: + command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, "-f", + workflow_zip_file_path, "-h", host_list, "-p", password_list] + subprocess.run(command, cwd=f"{get_root_dir()}/") From 332ef1490aced5c25afb360f92f626f5b8dafc0c Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:54:05 -0400 Subject: [PATCH 26/36] changes to run from folder --- pygeoweaver/sc_run.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 1597c1b..aef5cdf 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -111,9 +111,11 @@ def run_workflow( if workflow_folder_path and not workflow_zip_file_path: # command to run workflow from folder - command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, - "-d", workflow_folder_path, "-h", host_list, "-p", password_list] - subprocess.run(command, cwd=f"{get_root_dir()}/") + # command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, + # "-d", workflow_folder_path, "-h", host_list, "-p", password_list] + command = f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" \ + f"-d {workflow_folder_path} -h {host_list} -p {password_list}" + subprocess.run(command, cwd=f"{get_root_dir()}/", shell=True) if not workflow_folder_path and workflow_zip_file_path: command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, "-f", From 8111ec8ae11e221a6acfc570de78891a11572f3d Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 17:57:35 -0400 Subject: [PATCH 27/36] added quotes for path --- pygeoweaver/sc_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index aef5cdf..9e33e33 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -114,7 +114,7 @@ def run_workflow( # command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, # "-d", workflow_folder_path, "-h", host_list, "-p", password_list] command = f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" \ - f"-d {workflow_folder_path} -h {host_list} -p {password_list}" + f"-d '{workflow_folder_path}' -h {host_list} -p {password_list}" subprocess.run(command, cwd=f"{get_root_dir()}/", shell=True) if not workflow_folder_path and workflow_zip_file_path: From 9a94277702a6ae6f6262ab2e705ef86b45ba2941 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 18:02:10 -0400 Subject: [PATCH 28/36] added debug log --- pygeoweaver/sc_run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 9e33e33..ac141ce 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -111,10 +111,10 @@ def run_workflow( if workflow_folder_path and not workflow_zip_file_path: # command to run workflow from folder - # command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, - # "-d", workflow_folder_path, "-h", host_list, "-p", password_list] command = f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" \ f"-d '{workflow_folder_path}' -h {host_list} -p {password_list}" + print('Running Commnad: ', f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" \ + f"-d '{workflow_folder_path}' -h {host_list}") subprocess.run(command, cwd=f"{get_root_dir()}/", shell=True) if not workflow_folder_path and workflow_zip_file_path: From 2b9f7da487eb28c8ff48996c551a1ba79f497a49 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Tue, 13 Jun 2023 18:04:43 -0400 Subject: [PATCH 29/36] fix -d args --- pygeoweaver/sc_run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index ac141ce..fc070e7 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -112,9 +112,9 @@ def run_workflow( if workflow_folder_path and not workflow_zip_file_path: # command to run workflow from folder command = f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" \ - f"-d '{workflow_folder_path}' -h {host_list} -p {password_list}" + f" -d '{workflow_folder_path}' -h {host_list} -p {password_list}" print('Running Commnad: ', f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" \ - f"-d '{workflow_folder_path}' -h {host_list}") + f" -d '{workflow_folder_path}' -h {host_list}") subprocess.run(command, cwd=f"{get_root_dir()}/", shell=True) if not workflow_folder_path and workflow_zip_file_path: From aee647d2d42ca530d26278ad2a38fd62a42ecfd9 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Wed, 14 Jun 2023 01:45:37 -0400 Subject: [PATCH 30/36] fixes for comments --- pygeoweaver/sc_detail.py | 6 +-- pygeoweaver/sc_find.py | 9 ++++ pygeoweaver/sc_run.py | 99 +++++++++++++++++++++++++++------------- pygeoweaver/sc_sync.py | 56 ++++++++++++++--------- 4 files changed, 112 insertions(+), 58 deletions(-) diff --git a/pygeoweaver/sc_detail.py b/pygeoweaver/sc_detail.py index ab42c70..1d92ed1 100644 --- a/pygeoweaver/sc_detail.py +++ b/pygeoweaver/sc_detail.py @@ -63,11 +63,9 @@ def detail_host(host_id): ) -def get_code_for_process(process_id): +def get_process_code(process_id): r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", data={'type': 'process', 'id': process_id}).json() - code = r['code'] - decoded_string = code - print(decoded_string) + print(['code']) diff --git a/pygeoweaver/sc_find.py b/pygeoweaver/sc_find.py index 15eddf0..caaa085 100644 --- a/pygeoweaver/sc_find.py +++ b/pygeoweaver/sc_find.py @@ -12,6 +12,9 @@ def get_process_by_name(process_name): for process in process_list: if process['name'] == process_name: matching_processes.append(process) + pd.set_option('display.max_columns', None) # Display all columns + pd.set_option('display.max_rows', None) # Display all rows + pd.set_option('display.expand_frame_repr', False) # Prevent truncation of columns pd.DataFrame(matching_processes) @@ -24,6 +27,9 @@ def get_process_by_id(process_id): for process in process_list: if process['id'] == process_id: matching_processes.append(process) + pd.set_option('display.max_columns', None) # Display all columns + pd.set_option('display.max_rows', None) # Display all rows + pd.set_option('display.expand_frame_repr', False) # Prevent truncation of columns pd.DataFrame(matching_processes) @@ -36,5 +42,8 @@ def get_process_by_language(language): for process in process_list: if process['lang'] == language: matching_processes.append(process) + pd.set_option('display.max_columns', None) # Display all columns + pd.set_option('display.max_rows', None) # Display all rows + pd.set_option('display.expand_frame_repr', False) # Prevent truncation of columns pd.DataFrame(matching_processes) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index fc070e7..374face 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -5,22 +5,22 @@ import requests -from . import constants from pygeoweaver.utils import ( download_geoweaver_jar, get_geoweaver_jar_path, get_java_bin_path, get_root_dir, ) +from . import constants def run_process( - *, - process_id: str, - host_id: str, - password: str = None, - environment: str = None, - sync_path: os.PathLike = None, + *, + process_id: str, + host_id: str, + password: str = None, + environment: str = None, + sync_path: os.PathLike = None, ): """ Run a process @@ -36,16 +36,21 @@ def run_process( if sync_path: if not os.path.exists(sync_path): - print('The specified path does nto exists') - print('Updating code on workflow with the given file path.\n') + print("The specified path does nto exists") + print("Updating code on workflow with the given file path.\n") f = open(sync_path, "r") context = f.read() f.close() - details = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", - data={'type': 'process', 'id': process_id}).json() - details['code'] = context - requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/edit/process", - data=json.dumps(details), headers={'Content-Type': 'application/json'}) + details = requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", + data={"type": "process", "id": process_id}, + ).json() + details["code"] = context + requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/edit/process", + data=json.dumps(details), + headers={"Content-Type": "application/json"}, + ) download_geoweaver_jar() subprocess.run( @@ -65,14 +70,14 @@ def run_process( def run_workflow( - *, - workflow_id: str, - workflow_folder_path: str = None, - workflow_zip_file_path: str = None, - environment_list: str = None, - host_list: str = None, - password_list: str = None, - sync_path: os.PathLike = None, + *, + workflow_id: str, + workflow_folder_path: str = None, + workflow_zip_file_path: str = None, + environment_list: str = None, + host_list: str = None, + password_list: str = None, + sync_path: os.PathLike = None, ): """ Usage:
run workflow [-d=] @@ -91,8 +96,11 @@ def run_workflow( download_geoweaver_jar() if password_list is None: - password_list = getpass.getpass(f"Enter password for host: ") - + password_list = [] + for host in host_list.split(","): + password = getpass.getpass(f"Enter password for host - {host}: ") + password_list.append(password) + password_list = ",".join(password_list) if sync_path: from . import sync_workflow @@ -105,19 +113,46 @@ def run_workflow( ) if workflow_id and not workflow_folder_path and not workflow_zip_file_path: - command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", - workflow_id, "-h", host_list, "-p", password_list] + command = [ + get_java_bin_path(), + "-jar", + get_geoweaver_jar_path(), + "run", + "workflow", + workflow_id, + "-h", + host_list, + "-p", + password_list, + ] subprocess.run(command, cwd=f"{get_root_dir()}/") if workflow_folder_path and not workflow_zip_file_path: # command to run workflow from folder - command = f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" \ - f" -d '{workflow_folder_path}' -h {host_list} -p {password_list}" - print('Running Commnad: ', f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" \ - f" -d '{workflow_folder_path}' -h {host_list}") + command = ( + f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" + f" -d '{workflow_folder_path}' -h {host_list} -p {password_list}" + ) + print( + "Running Commnad: ", + f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" + f" -d '{workflow_folder_path}' -h {host_list}", + ) subprocess.run(command, cwd=f"{get_root_dir()}/", shell=True) if not workflow_folder_path and workflow_zip_file_path: - command = [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, "-f", - workflow_zip_file_path, "-h", host_list, "-p", password_list] + command = [ + get_java_bin_path(), + "-jar", + get_geoweaver_jar_path(), + "run", + "workflow", + workflow_id, + "-f", + workflow_zip_file_path, + "-h", + host_list, + "-p", + password_list, + ] subprocess.run(command, cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/sc_sync.py b/pygeoweaver/sc_sync.py index 87b4195..2d226cd 100644 --- a/pygeoweaver/sc_sync.py +++ b/pygeoweaver/sc_sync.py @@ -12,39 +12,51 @@ ) -def sync(process_id: str, sync_to_path: typing.Union[str, os.PathLike], direction: str): - print(f'Proceeding with {direction}\n') +def sync(process_id: str, local_path: typing.Union[str, os.PathLike], direction: str): + print(f"Proceeding with {direction}\n") if direction == "download": - if not sync_to_path: + if not local_path: raise Exception("Sync path not found.") - r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", - data={'type': 'process', 'id': process_id}).json() - code = r['code'] + r = requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", + data={"type": "process", "id": process_id}, + ).json() + code = r["code"] decoded_string = code - file_name = r['name'] + file_name = r["name"] ext = None - if r['lang'] == "python": + if r["lang"] == "python": ext = ".py" - elif r['lang'] == "bash": + elif r["lang"] == "shell": ext = ".sh" + elif r["lang"] == "builtin": + pass # TODO: need to figure out what is builtin extension name + elif r["lang"] == "jupyter": + ext = "ipynb" else: raise Exception("Unknown file format.") - with open(os.path.join(sync_to_path, file_name + ext), 'w') as file: + with open(os.path.join(local_path, file_name + ext), "w") as file: file.write(decoded_string) - print(f'Wrote file {file_name + ext} to {sync_to_path}') + print(f"Wrote file {file_name + ext} to {local_path}") elif direction == "upload": - if not sync_to_path: + if not local_path: raise Exception("Sync path not found.") - process_prev_state = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", - data={'type': 'process', 'id': process_id}).json() - f = open(sync_to_path, 'r') - f_content = f.read() - f.close() - process_prev_state['code'] = f_content - requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/edit/process", - data=json.dumps(process_prev_state), headers={'Content-Type': 'application/json'}) + process_prev_state = requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", + data={"type": "process", "id": process_id}, + ).json() + with open(local_path, "r") as f: + f_content = f.read() + process_prev_state["code"] = f_content + requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/edit/process", + data=json.dumps(process_prev_state), + headers={"Content-Type": "application/json"}, + ) else: - raise Exception("Please specify the direction to sync. Choices - [UPLOAD, DOWNLOAD]") + raise Exception( + "Please specify the direction to sync. Choices - [UPLOAD, DOWNLOAD]" + ) def sync_workflow(workflow_id: str, sync_to_path: typing.Union[str, os.PathLike]): @@ -61,7 +73,7 @@ def sync_workflow(workflow_id: str, sync_to_path: typing.Union[str, os.PathLike] os.makedirs(tmp_dir) # unzip the workflow with zipfile.ZipFile( - os.path.join(home_dir, "gw-workspace", "temp", filename) + os.path.join(home_dir, "gw-workspace", "temp", filename) ) as ref: ref.extractall(os.path.join(home_dir, "tmp")) # check if target workflow path and the unzipped workflow match From a5f8f32d4cbfbcb51d7b0fa872352d35c5fae3f4 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Wed, 14 Jun 2023 09:46:34 -0400 Subject: [PATCH 31/36] buitin process does not have type --- pygeoweaver/sc_sync.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pygeoweaver/sc_sync.py b/pygeoweaver/sc_sync.py index 2d226cd..187d876 100644 --- a/pygeoweaver/sc_sync.py +++ b/pygeoweaver/sc_sync.py @@ -29,8 +29,6 @@ def sync(process_id: str, local_path: typing.Union[str, os.PathLike], direction: ext = ".py" elif r["lang"] == "shell": ext = ".sh" - elif r["lang"] == "builtin": - pass # TODO: need to figure out what is builtin extension name elif r["lang"] == "jupyter": ext = "ipynb" else: From 071ad0463d8eb3d88ea23802bbb5e89d90d3f2aa Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Wed, 14 Jun 2023 11:01:03 -0400 Subject: [PATCH 32/36] fixes --- pygeoweaver/sc_run.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 374face..792391f 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -100,6 +100,9 @@ def run_workflow( for host in host_list.split(","): password = getpass.getpass(f"Enter password for host - {host}: ") password_list.append(password) + elif len(password_list.split(",")) != len(host_list.split(",")): + raise RuntimeError("The password list length doesn't match host list") + password_list = ",".join(password_list) if sync_path: from . import sync_workflow @@ -125,6 +128,8 @@ def run_workflow( "-p", password_list, ] + if environment_list: + command.extend(["-e", environment_list]) subprocess.run(command, cwd=f"{get_root_dir()}/") if workflow_folder_path and not workflow_zip_file_path: @@ -133,11 +138,8 @@ def run_workflow( f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" f" -d '{workflow_folder_path}' -h {host_list} -p {password_list}" ) - print( - "Running Commnad: ", - f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" - f" -d '{workflow_folder_path}' -h {host_list}", - ) + if environment_list: + command += f" -e {environment_list}" subprocess.run(command, cwd=f"{get_root_dir()}/", shell=True) if not workflow_folder_path and workflow_zip_file_path: @@ -155,4 +157,6 @@ def run_workflow( "-p", password_list, ] + if environment_list: + command.extend(["-e", environment_list]) subprocess.run(command, cwd=f"{get_root_dir()}/") From 9f2f97d420e1d8ebbee750cc371b6b17da51ec82 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Wed, 14 Jun 2023 11:01:57 -0400 Subject: [PATCH 33/36] fixes --- pygeoweaver/sc_run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index 792391f..dc25901 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -96,6 +96,7 @@ def run_workflow( download_geoweaver_jar() if password_list is None: + # prompt to ask for password password_list = [] for host in host_list.split(","): password = getpass.getpass(f"Enter password for host - {host}: ") From b59505e2c23875bb13a7e587210e21aea5fcea2c Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Wed, 14 Jun 2023 11:06:18 -0400 Subject: [PATCH 34/36] black reformat all files --- pygeoweaver/sc_detail.py | 10 ++++----- pygeoweaver/sc_export.py | 12 ++++++----- pygeoweaver/sc_find.py | 37 +++++++++++++++++++-------------- pygeoweaver/sc_help.py | 4 +++- pygeoweaver/sc_history.py | 8 +++---- pygeoweaver/sc_import.py | 10 ++++----- pygeoweaver/sc_list.py | 18 +++++++++------- pygeoweaver/sc_resetpassword.py | 13 ++++++++---- pygeoweaver/server.py | 1 + 9 files changed, 65 insertions(+), 48 deletions(-) diff --git a/pygeoweaver/sc_detail.py b/pygeoweaver/sc_detail.py index 1d92ed1..7274bae 100644 --- a/pygeoweaver/sc_detail.py +++ b/pygeoweaver/sc_detail.py @@ -64,8 +64,8 @@ def detail_host(host_id): def get_process_code(process_id): - r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", - data={'type': 'process', 'id': process_id}).json() - print(['code']) - - + r = requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", + data={"type": "process", "id": process_id}, + ).json() + print(["code"]) diff --git a/pygeoweaver/sc_export.py b/pygeoweaver/sc_export.py index 6629b52..bd34798 100644 --- a/pygeoweaver/sc_export.py +++ b/pygeoweaver/sc_export.py @@ -9,7 +9,9 @@ ) -def export_workflow(workflow_id, mode=4, target_file_path=None, unzip=False, unzip_directory_name=None): +def export_workflow( + workflow_id, mode=4, target_file_path=None, unzip=False, unzip_directory_name=None +): """ Usage:
export workflow [--mode=] @@ -42,7 +44,7 @@ def export_workflow(workflow_id, mode=4, target_file_path=None, unzip=False, unz if unzip: if not unzip_directory_name: raise Exception("Please provide unzip directory name") - with zipfile.ZipFile(target_file_path, 'r') as zip_ref: - zip_ref.extractall(os.path.join(os.path.dirname(target_file_path), unzip_directory_name)) - - + with zipfile.ZipFile(target_file_path, "r") as zip_ref: + zip_ref.extractall( + os.path.join(os.path.dirname(target_file_path), unzip_directory_name) + ) diff --git a/pygeoweaver/sc_find.py b/pygeoweaver/sc_find.py index caaa085..05a089d 100644 --- a/pygeoweaver/sc_find.py +++ b/pygeoweaver/sc_find.py @@ -4,46 +4,51 @@ def get_process_by_name(process_name): - response = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={'type': 'process'}) + response = requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={"type": "process"} + ) process_list = response.json() matching_processes = [] for process in process_list: - if process['name'] == process_name: + if process["name"] == process_name: matching_processes.append(process) - pd.set_option('display.max_columns', None) # Display all columns - pd.set_option('display.max_rows', None) # Display all rows - pd.set_option('display.expand_frame_repr', False) # Prevent truncation of columns + pd.set_option("display.max_columns", None) # Display all columns + pd.set_option("display.max_rows", None) # Display all rows + pd.set_option("display.expand_frame_repr", False) # Prevent truncation of columns pd.DataFrame(matching_processes) def get_process_by_id(process_id): - response = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={'type': 'process'}) + response = requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={"type": "process"} + ) process_list = response.json() matching_processes = [] for process in process_list: - if process['id'] == process_id: + if process["id"] == process_id: matching_processes.append(process) - pd.set_option('display.max_columns', None) # Display all columns - pd.set_option('display.max_rows', None) # Display all rows - pd.set_option('display.expand_frame_repr', False) # Prevent truncation of columns + pd.set_option("display.max_columns", None) # Display all columns + pd.set_option("display.max_rows", None) # Display all rows + pd.set_option("display.expand_frame_repr", False) # Prevent truncation of columns pd.DataFrame(matching_processes) def get_process_by_language(language): - response = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={'type': 'process'}) + response = requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/list", data={"type": "process"} + ) process_list = response.json() matching_processes = [] for process in process_list: - if process['lang'] == language: + if process["lang"] == language: matching_processes.append(process) - pd.set_option('display.max_columns', None) # Display all columns - pd.set_option('display.max_rows', None) # Display all rows - pd.set_option('display.expand_frame_repr', False) # Prevent truncation of columns + pd.set_option("display.max_columns", None) # Display all columns + pd.set_option("display.max_rows", None) # Display all rows + pd.set_option("display.expand_frame_repr", False) # Prevent truncation of columns pd.DataFrame(matching_processes) - diff --git a/pygeoweaver/sc_help.py b/pygeoweaver/sc_help.py index 3fc12ac..572984e 100644 --- a/pygeoweaver/sc_help.py +++ b/pygeoweaver/sc_help.py @@ -2,7 +2,9 @@ from pygeoweaver.utils import get_geoweaver_jar_path, get_java_bin_path, get_root_dir -def helpwith(command_list: list = [],): +def helpwith( + command_list: list = [], +): target_cmd_args = [get_java_bin_path(), "-jar", get_geoweaver_jar_path()] if len(command_list) > 0: for i in range(len(command_list) - 1): diff --git a/pygeoweaver/sc_history.py b/pygeoweaver/sc_history.py index 383107a..b9df81a 100644 --- a/pygeoweaver/sc_history.py +++ b/pygeoweaver/sc_history.py @@ -39,8 +39,8 @@ def get_process_history(process_id): data={"type": "process", "id": process_id}, ).json() df = pd.DataFrame(r) - df['history_begin_time'] = pd.to_datetime(df['history_begin_time'], unit='ms') - df['history_end_time'] = pd.to_datetime(df['history_end_time'], unit='ms') + df["history_begin_time"] = pd.to_datetime(df["history_begin_time"], unit="ms") + df["history_end_time"] = pd.to_datetime(df["history_end_time"], unit="ms") return df except Exception as e: subprocess.run( @@ -63,8 +63,8 @@ def get_workflow_history(workflow_id): data={"type": "workflow", "id": workflow_id}, ).json() df = pd.DataFrame(r) - df['history_begin_time'] = pd.to_datetime(df['history_begin_time'], unit='ms') - df['history_end_time'] = pd.to_datetime(df['history_end_time'], unit='ms') + df["history_begin_time"] = pd.to_datetime(df["history_begin_time"], unit="ms") + df["history_end_time"] = pd.to_datetime(df["history_end_time"], unit="ms") return df except Exception as e: subprocess.run( diff --git a/pygeoweaver/sc_import.py b/pygeoweaver/sc_import.py index a7fe02b..af7e244 100644 --- a/pygeoweaver/sc_import.py +++ b/pygeoweaver/sc_import.py @@ -9,11 +9,11 @@ def import_workflow(workflow_zip_file_path): """ - Usage:
import workflow - import a workflow from file - - Geoweaver workflow zip file path - """ + Usage:
import workflow + import a workflow from file + + Geoweaver workflow zip file path + """ if not workflow_zip_file_path: raise RuntimeError("Workflow zip file path is missing") download_geoweaver_jar() diff --git a/pygeoweaver/sc_list.py b/pygeoweaver/sc_list.py index 1218930..265b2d3 100644 --- a/pygeoweaver/sc_list.py +++ b/pygeoweaver/sc_list.py @@ -7,7 +7,8 @@ download_geoweaver_jar, get_geoweaver_jar_path, get_java_bin_path, - get_root_dir, check_ipython, + get_root_dir, + check_ipython, ) import pandas as pd @@ -31,13 +32,14 @@ def list_processes(): def list_processes_in_workflow(workflow_id): download_geoweaver_jar() - payload = { - 'id': workflow_id, - 'type': 'workflow' - } - r = requests.post(f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", data=payload) - nodes = json.loads(r.json()['nodes']) - result = [{'title': item['title'], 'id': item['id'].split('.')[0]} for item in nodes] + payload = {"id": workflow_id, "type": "workflow"} + r = requests.post( + f"{constants.GEOWEAVER_DEFAULT_ENDPOINT_URL}/web/detail", data=payload + ) + nodes = json.loads(r.json()["nodes"]) + result = [ + {"title": item["title"], "id": item["id"].split(".")[0]} for item in nodes + ] if check_ipython(): return pd.DataFrame(result) diff --git a/pygeoweaver/sc_resetpassword.py b/pygeoweaver/sc_resetpassword.py index e2c90a7..b605ecc 100644 --- a/pygeoweaver/sc_resetpassword.py +++ b/pygeoweaver/sc_resetpassword.py @@ -9,10 +9,15 @@ def reset_password(): """ - Usage:
resetpassword - Reset password for localhost - """ + Usage:
resetpassword + Reset password for localhost + """ download_geoweaver_jar() subprocess.run( - [get_java_bin_path(), "-jar", get_geoweaver_jar_path(), "resetpassword",] + [ + get_java_bin_path(), + "-jar", + get_geoweaver_jar_path(), + "resetpassword", + ] ) diff --git a/pygeoweaver/server.py b/pygeoweaver/server.py index 6356389..2d630c1 100644 --- a/pygeoweaver/server.py +++ b/pygeoweaver/server.py @@ -59,6 +59,7 @@ def show(geoweaver_url=GEOWEAVER_DEFAULT_ENDPOINT_URL): if check_ipython(): logger.info("enter ipython block") from IPython.display import IFrame + logger.warning("This only works when the Jupyter is visited from localhost!") return IFrame(src=geoweaver_url, width="100%", height="500px") else: From 16eb2867cae12aa64036a59fe4eb9ded60979995 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Wed, 14 Jun 2023 11:18:52 -0400 Subject: [PATCH 35/36] revert change for workflow folder path --- pygeoweaver/sc_run.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pygeoweaver/sc_run.py b/pygeoweaver/sc_run.py index dc25901..0b848da 100644 --- a/pygeoweaver/sc_run.py +++ b/pygeoweaver/sc_run.py @@ -135,13 +135,23 @@ def run_workflow( if workflow_folder_path and not workflow_zip_file_path: # command to run workflow from folder - command = ( - f"{get_java_bin_path()} -jar {get_geoweaver_jar_path()} run workflow {workflow_id}" - f" -d '{workflow_folder_path}' -h {host_list} -p {password_list}" - ) + command = [ + get_java_bin_path(), + "-jar", + get_geoweaver_jar_path(), + "run", + "workflow", + workflow_id, + "-d", + workflow_folder_path, + "-h", + host_list, + "-p", + password_list + ] if environment_list: - command += f" -e {environment_list}" - subprocess.run(command, cwd=f"{get_root_dir()}/", shell=True) + command.extend(["-e", environment_list]) + subprocess.run(command, cwd=f"{get_root_dir()}/") if not workflow_folder_path and workflow_zip_file_path: command = [ From 2fde1cdeaef10ab594280b55150f061cc64d038a Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Wed, 14 Jun 2023 11:25:59 -0400 Subject: [PATCH 36/36] Update sc_import.py --- pygeoweaver/sc_import.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pygeoweaver/sc_import.py b/pygeoweaver/sc_import.py index a7fe02b..4a76679 100644 --- a/pygeoweaver/sc_import.py +++ b/pygeoweaver/sc_import.py @@ -28,3 +28,6 @@ def import_workflow(workflow_zip_file_path): ], cwd=f"{get_root_dir()}/", ) + +def import_workflow_from_github(git_repo_url): + pass