From 6be3ecb9317b1c9c5a83c9daedae37873170fcbb Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Mon, 3 Apr 2023 01:03:56 -0400 Subject: [PATCH 01/27] fix server --- .gitignore | 3 +++ pygeoweaver/{detail_workflow.py => detail.py} | 0 pygeoweaver/main.py | 14 ++++++++++++++ pygeoweaver/server.py | 13 ++++++------- pygeoweaver/start.sh | 14 ++++++++------ pygeoweaver/stop.sh | 12 ++++++++++-- pygeoweaver/utils.py | 6 ++++++ pyproject.toml | 7 +++---- setup.cfg | 3 --- setup.py | 3 --- 10 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 .gitignore rename pygeoweaver/{detail_workflow.py => detail.py} (100%) create mode 100644 pygeoweaver/main.py create mode 100644 pygeoweaver/utils.py delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..70c1748 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/* +dist/* +*egg-info* \ No newline at end of file diff --git a/pygeoweaver/detail_workflow.py b/pygeoweaver/detail.py similarity index 100% rename from pygeoweaver/detail_workflow.py rename to pygeoweaver/detail.py diff --git a/pygeoweaver/main.py b/pygeoweaver/main.py new file mode 100644 index 0000000..792b612 --- /dev/null +++ b/pygeoweaver/main.py @@ -0,0 +1,14 @@ +""" +The main function of pygeoweaver +To run in CLI mode. +""" +from server import start, stop + +def main(): + # start geoweaver + #start() + # stop geoweaver + stop() + +if __name__ == "__main__": + main() diff --git a/pygeoweaver/server.py b/pygeoweaver/server.py index 53bd8ef..5a6fe1b 100644 --- a/pygeoweaver/server.py +++ b/pygeoweaver/server.py @@ -1,5 +1,6 @@ - +import os import subprocess +from utils import get_root_dir """ This module provides function to start and stop Geoweaver server. @@ -17,16 +18,14 @@ def download_geoweaver(): def start(): print("start Geoweaver instance..") - result = subprocess.run(['start.sh'], capture_output=True, text=True) - print(result.stdout) - print(result.stderr) + result = subprocess.run(['./start.sh'], cwd=f"{get_root_dir()}/") + def stop(): print("stop Geoweaver instance..") - result = subprocess.run(['stop.sh'], capture_output=True, text=True) - print(result.stdout) - print(result.stderr) + result = subprocess.run(['./stop.sh'], cwd=f"{get_root_dir()}/", shell=True) + diff --git a/pygeoweaver/start.sh b/pygeoweaver/start.sh index 8bb83ef..a3ee485 100755 --- a/pygeoweaver/start.sh +++ b/pygeoweaver/start.sh @@ -1,15 +1,16 @@ #!/bin/bash +echo "Stop running Geoweaver if any.." +pkill -f geoweaver + FILE=~/geoweaver.jar if [ -f "$FILE" ]; then - echo "$FILE exists. Skip downloading.." -else - echo "Downloading the latest geoweaver.jar to user home directory" - cd ~ && curl -OL https://github.com/ESIPFed/Geoweaver/releases/download/latest/geoweaver.jar + echo "$FILE exists. Remove.." + rm -f $FILE fi -echo "Stop running Geoweaver if any.." -kill $(ps aux | grep 'geoweaver.jar' | awk '{print $2}') +echo "Downloading the latest geoweaver.jar to user home directory" +cd ~ && curl -OL https://github.com/ESIPFed/Geoweaver/releases/download/latest/geoweaver.jar echo "Start Geoweaver.." nohup java -jar ~/geoweaver.jar > ~/geoweaver.log & @@ -23,6 +24,7 @@ do ((counter++)) done +cat ~/geoweaver.log if [ $counter == 20 ] ; then echo "Error: Geoweaver is not up" exit 1 diff --git a/pygeoweaver/stop.sh b/pygeoweaver/stop.sh index 7f806e0..51c10b9 100755 --- a/pygeoweaver/stop.sh +++ b/pygeoweaver/stop.sh @@ -1,5 +1,13 @@ #!/bin/bash - - +echo "Stop running Geoweaver if any.." +pkill -f geoweaver +STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "http://localhost:8070/Geoweaver") +if [ $STATUS != 302 ]; then + echo "Stopped." + exit 0 +else + echo "Error: unable to stop." + exit 1 +fi diff --git a/pygeoweaver/utils.py b/pygeoweaver/utils.py new file mode 100644 index 0000000..79c818f --- /dev/null +++ b/pygeoweaver/utils.py @@ -0,0 +1,6 @@ +import os + +def get_root_dir(): + print(os.path.basename(__file__)) + head, tail = os.path.split(__file__) + return head \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 835efec..42d719d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,10 @@ [build-system] -requires = [ - -] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" [project] name = "pygeoweaver" -version = "0.0.1" +version = "0.6.0" authors = [ { name="Geoweaver team", email="geoweaver.app@gmail.com" }, ] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b28b04f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/setup.py b/setup.py deleted file mode 100644 index b28b04f..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ - - - From 59e91aae6b84b35d6415ef6be497e679372e6e63 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Mon, 3 Apr 2023 01:26:59 -0400 Subject: [PATCH 02/27] Update run_workflow.py --- pygeoweaver/run_workflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygeoweaver/run_workflow.py b/pygeoweaver/run_workflow.py index dd46255..eec8be1 100644 --- a/pygeoweaver/run_workflow.py +++ b/pygeoweaver/run_workflow.py @@ -1,6 +1,6 @@ -def run_workflow(): +def run_workflow(workflow_id, host_id, env_id, password_list): print("Run workflow: ") pass \ No newline at end of file From e4845ab5b22af85d351d23e0cf6b3a6da7f77196 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Tue, 11 Apr 2023 00:34:19 -0400 Subject: [PATCH 03/27] working --- pygeoweaver/__main__.py | 25 +++++++++++++ .../__pycache__/__init__.cpython-39.pyc | Bin 154 -> 154 bytes .../__pycache__/__main__.cpython-39.pyc | Bin 0 -> 698 bytes .../history_process.cpython-39.pyc | Bin 0 -> 583 bytes .../__pycache__/list_hosts.cpython-39.pyc | Bin 0 -> 503 bytes .../__pycache__/list_processes.cpython-39.pyc | Bin 0 -> 557 bytes .../__pycache__/list_workflows.cpython-39.pyc | Bin 0 -> 515 bytes pygeoweaver/__pycache__/server.cpython-39.pyc | Bin 0 -> 809 bytes pygeoweaver/__pycache__/utils.cpython-39.pyc | Bin 0 -> 1369 bytes pygeoweaver/detail.py | 6 ---- pygeoweaver/detail_host.py | 10 ++++++ pygeoweaver/detail_process.py | 10 ++++++ pygeoweaver/detail_workflow.py | 11 ++++++ pygeoweaver/download_gw.sh | 9 +++++ pygeoweaver/export_workflow.py | 24 +++++++++++-- pygeoweaver/history_process.py | 9 +++++ pygeoweaver/history_workflow.py | 9 +++++ pygeoweaver/import_workflow.py | 17 +++++++-- pygeoweaver/list_hosts.py | 6 ++-- pygeoweaver/list_processes.py | 8 +++-- pygeoweaver/list_workflows.py | 8 ++--- pygeoweaver/main.py | 14 -------- pygeoweaver/run_process.py | 10 ++++++ pygeoweaver/run_workflow.py | 32 ++++++++++++++--- pygeoweaver/server.py | 2 +- pygeoweaver/start.sh | 7 ---- pygeoweaver/utils.py | 34 ++++++++++++++++-- 27 files changed, 203 insertions(+), 48 deletions(-) create mode 100644 pygeoweaver/__main__.py create mode 100644 pygeoweaver/__pycache__/__main__.cpython-39.pyc create mode 100644 pygeoweaver/__pycache__/history_process.cpython-39.pyc create mode 100644 pygeoweaver/__pycache__/list_hosts.cpython-39.pyc create mode 100644 pygeoweaver/__pycache__/list_processes.cpython-39.pyc create mode 100644 pygeoweaver/__pycache__/list_workflows.cpython-39.pyc create mode 100644 pygeoweaver/__pycache__/server.cpython-39.pyc create mode 100644 pygeoweaver/__pycache__/utils.cpython-39.pyc delete mode 100644 pygeoweaver/detail.py create mode 100644 pygeoweaver/detail_host.py create mode 100644 pygeoweaver/detail_process.py create mode 100644 pygeoweaver/detail_workflow.py create mode 100644 pygeoweaver/download_gw.sh delete mode 100644 pygeoweaver/main.py create mode 100644 pygeoweaver/run_process.py diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py new file mode 100644 index 0000000..030339c --- /dev/null +++ b/pygeoweaver/__main__.py @@ -0,0 +1,25 @@ +""" +The main function of pygeoweaver +To run in CLI mode. +""" +from pygeoweaver.history_process import show_process_history +from pygeoweaver.list_hosts import list_hosts +from pygeoweaver.list_processes import list_processes +from pygeoweaver.list_workflows import list_workflows +from pygeoweaver.server import start, stop + +def main(): + # start geoweaver + #start() + # stop geoweaver + # stop() + # list resources + #list_hosts() + #list_processes() + #list_workflows() + # show history + show_process_history("xxx") + + +if __name__ == "__main__": + main() diff --git a/pygeoweaver/__pycache__/__init__.cpython-39.pyc b/pygeoweaver/__pycache__/__init__.cpython-39.pyc index 77a8efc36307169313f741c9ef40d294e9d44173..55bee5305fe72ea6530b83caaed8dd391b56f60e 100644 GIT binary patch delta 19 ZcmbQmIE#@xk(ZZ?0SMA`wI*`+0{|n)1Frx8 delta 19 ZcmbQmIE#@xk(ZZ?0SJ_gb2+rASOn z`~nl_Kxq(MjvU}J*XUxxNlarWp~~S7wYZkl zl*`=`yGdO&c%#Jiq^UgamAH|#6yr>_c^l(q>^&3Sk=?j;?*NybCxTgaL3-`S9dAm3k_}2MO#_`;ezTG6rX-zS6Pm`|KSzM_y>LZbo`4CZHo} zj2MkgreWTr1xpZ$kv5sZXr+w4S#p_~YPcUJdTM%3Q8!r#S>a-bNo2cM&5AO>Wjg3G zl;Mfu2n0uP&UtM%n}KD#5NP46bRYY{m62eAJ1v7F9py@`FY1sc(VWA4t@H@UyWh})3*A_Sb6o0gW z`u~I<>7Zc=Yt;@oHy#``u>hWRi=C&Tl0qy+`a8nu5WW*B#R%*IEz-;$tD(`-p+iv==wGG`4Z3I%6dz&JkVJ!|VmQbYw_~56 z=mYd+@&H7(PI-k)J-Tk{^nm+#JRU!OcdSRFePFx3c|l(h;8)!2TEd$*?Cu!@0bv7W zT$2Xdq)b{-idL2qfdt7fP^N^Zkf*m?4JWw>hh&yrV`{3V$}ClVu52~0Z8)4N|1ec8 zYCj9Zn779GinN`uqI-*R#{QPwy=1rqH}tG%jaTS#4G2D&3ra|MxdxJ#Fim~BhVMY> zkA$*s39AHFw|8>!^jJG@>}srOtlhZP&gpI%h>(3U}Oq6p$*uJxZvsN0;pwLk99ipA=FTo2;EG+WxE#VQ=QnORo8s5m4C`N)f<^RFygCW@TxV`H|ll#4i~!|;DPuJ3yPXL literal 0 HcmV?d00001 diff --git a/pygeoweaver/__pycache__/list_hosts.cpython-39.pyc b/pygeoweaver/__pycache__/list_hosts.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8c0357b2d39507dadf02641b504839b0b0eb7845 GIT binary patch literal 503 zcmY*W%}T>S5T4ylVq4pTAbkb{wgK@dqA2L87x9uyNV7|ukaWZDrlq~st4|<4fUmS3 zJ^2bfIopD52j-XA@B4;Ld%X^zU438kHUao?&7o0j?$GrG1`eE*5W7rEQqh=JEM}D# zdjvS+-W$X|Cod5Czqk#fkl8+$i&-gCo=k*Xh;%MgQl!fEC&C<$k~%e0+jVm#rAc_M zGKX?#0X7fl`VxbIH4reQpqy}O*m|pB;u~)bAHe-j%7b@`$^aFejI39r^K|769KBcO z+N^@XU@EoQkSHXUWeXnq${lPwx*69>W_d1?tq*E^O|jS1pu|3MryT znKhM|867?4=D8V1_45DXquMbij#dxrrS0rnA0f5l01^<@!yE>xjme%JU=16SmwGF6 cuWGx!7q+Xq?rH0$lDsL!Eq?9}y+zL1AAVYUJOBUy literal 0 HcmV?d00001 diff --git a/pygeoweaver/__pycache__/list_processes.cpython-39.pyc b/pygeoweaver/__pycache__/list_processes.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f2b959a42beb72f2808c7d739a8f8a6aaed80d36 GIT binary patch literal 557 zcmZ8fy-ve05I+B;w5UZwLLHfjP@9DjAtXQ`1{TDUB}#LqBueVab|`c$D^GxU03L@C zuS~oG6LzU+%Sm^>`|f=A>Fl)A*#sx=9|w3#06u-ND%1tXPW7HM2uMnZ{Ygtw(U?{& zW)+V)0c6OZAP$gRLl}IyYPbrS?V_BFN||CZ6mlZcd!dpdRkk}6W*th#skyUlk1Hun zg1O3kmsM%F;KZrEbjH982pCdOBuEXL!H^j~gBQo;l_Gzpi)?@mpT!Mq4uk&{2##;- z$_Ck8C2>mkAHGQx63em)T3)30>6G_8V_xRkOk2I)SjkLi9R|uT$8PF+uz)O6^++*? zD(=i1sJ8dL`96zov`{)Kq=-&sR##$VbabAZi+T`^AOE(q=KGP!qPfuh@uS^Zhx{1r zw*sU=c8S_@Uf59nP3`td*M4pCQqKu5`OT}B6o0*rzuG)>yQoWXVjCZL}_eFLQ+Sz(}=ERCbl?5xeBXC+((Sgv+S%7BJ3s*6uGlnei%aY3*a8EF3W!|91uAibOA?Wi zMic=fjJ`tTF?0`s_hYAF7!cEAqL~yTVey!Yh9^@l<2;e3H|Bb~6<3LVG9A~KLg<)f zGId)v&9}vsb#-Dv!yFK3lw*b%)?~iaF!nT^!#gnV12g{(TV-Gs?F-*1F`ek??@Kw*FkNgEb;(j9HusvcERq+BUOWId6@b|tm&33AWn4i-1zgW^(! zx!~coNb8bMvgE6Ht=zH4f7EJFy_o&&mZMP)0QpFEZ47+5YlAu5*g2?m hR;Z=iwYuf>THq?{xTmf2Qn0$<7xtr9+gs=e{{jztfQJA8 literal 0 HcmV?d00001 diff --git a/pygeoweaver/__pycache__/server.cpython-39.pyc b/pygeoweaver/__pycache__/server.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..94fc136c287026edfd601159742c997f85f84b2a GIT binary patch literal 809 zcmaJ0R;shBvx9gG(eLk%8spMR+I7Q+C!8`R7*p# zUx4_4d=L_vmWp54ies~oSwLLL_hI{ykG;S$Pv9hz zykfJTkPFmZ!EU9q2 zed8!zVwn)mcZ%JkQ3^ZJo4V2qnVu@WQHytqQmfO}Ag=UUr9e}K)wK1ur+Y>LAP(;8 zS^gH6O@6Lbexi$Zt!iuX)6%|b&+=xw`~`a>M+d%?HQVm4ydGfw`{vjU>hxhDMesM+ zI3|vSXY&Aw1)mGfndRp~iY2$f1^WcmJ_{LMiuceIIz`jnePb77do;@$J9VM5Y&Xhs zf0~)q70;n&P;BHr?4pLs+IAz;o;9QkWlR@PTaz1Z&%2nEX)AjWgWP0YQgL}>hK`7Cz=L97zL^LbAY!DIswzs5lau$) zkwe#YjDy3(w^2<7ozRBdpWNN)y=B(gvNB!<|3aP~xsD!i;7Tt@@^r0bTdC*n@r*-D Lpvicc43hW-9Pe$D?;&ia$NZ{-Vw9 zKpVS<(+p4uCZJ@)wT2-ydp_iX3-1LRdcqe0YF~t+g*p(CXrm5APh1e)7cguIIA(GG zZ@h~g0W0qiL@cVPU8Snr`}E z6d&ayng6_xgPb=IKEU-L2b7yZ)uA#q82-S8Wh97YZPQs1uK24@mfpfU>n!;A0^Rikdi(gTJiPbP z7tB2QoI&&bh_Z?Qo9&9$isDALC!!Vniq8gn(mrxQKAI>o=eM4oLlT4Y@|l=_JF>Pi zx0B?wu%r6qFjtf0!SOfW4WvjOZrQ74DKjHYBGhbJs!SwhW~H(FU3PqSGXHpciW+}V zn1jt3Ddsl@NW259wzh+9;~SdvHPyMHunV=ED11891=lh4Nu^aTjd7l?rwt`tq~$L) z!ay66$oZ<0Qy0v1Vdb!utEt7;=z>ZYsJh?RQ(H{r1Fe;g{b8H#Uc2_TAktcw4zz>E zJ0w}Nbd$wCMLtAu<{AnHA^6beH^ApUba)?b@(?h|!@P=HeVqhxr%7W? h$|iAg-iiGFkwkZ}b#*E45(5n}J_7uB export workflow [--mode=] + + Geoweaver workflow ID + target file path to save the workflow zip + --mode= exportation model options: + 1 - workflow only + 2 - workflow with process code + 3 - workflow with process code and only good + history + 4 - workflow with process code and all the + history.default option is 4. + """ + if not workflow_id: + raise RuntimeError("Workflow id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "export", "workflow", workflow_id, target_file_path, + "--mode", mode,], + cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/history_process.py b/pygeoweaver/history_process.py index e69de29..d691ee5 100644 --- a/pygeoweaver/history_process.py +++ b/pygeoweaver/history_process.py @@ -0,0 +1,9 @@ +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir + + +def show_process_history(process_history_id): + if not process_history_id: + raise RuntimeError("Process history id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "history", process_history_id], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/history_workflow.py b/pygeoweaver/history_workflow.py index e69de29..57c745b 100644 --- a/pygeoweaver/history_workflow.py +++ b/pygeoweaver/history_workflow.py @@ -0,0 +1,9 @@ +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir + + +def show_workflow_history(workflow_history_id): + if not workflow_history_id: + raise RuntimeError("Workflow history id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "history", workflow_history_id], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/import_workflow.py b/pygeoweaver/import_workflow.py index a1a320d..ea112ec 100644 --- a/pygeoweaver/import_workflow.py +++ b/pygeoweaver/import_workflow.py @@ -1,6 +1,17 @@ +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - -def import_workflow(): - print("import workflow") +def import_workflow(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() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "import", "workflow", workflow_zip_file_path], + cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/list_hosts.py b/pygeoweaver/list_hosts.py index e05e379..a8f9ca7 100644 --- a/pygeoweaver/list_hosts.py +++ b/pygeoweaver/list_hosts.py @@ -1,5 +1,7 @@ +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir def list_hosts(): - print("List all hosts") - pass + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--host"], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/list_processes.py b/pygeoweaver/list_processes.py index 9e7a569..3b7f6b0 100644 --- a/pygeoweaver/list_processes.py +++ b/pygeoweaver/list_processes.py @@ -1,5 +1,7 @@ - +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir def list_processes(): - print("all the geoweaver cli") - pass \ No newline at end of file + download_geoweaver_jar() + subprocess.run(["chmod", "+x", get_geoweaver_jar_path()], cwd=f"{get_root_dir()}/") + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--process"], cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/list_workflows.py b/pygeoweaver/list_workflows.py index 5437f5c..5a96d44 100644 --- a/pygeoweaver/list_workflows.py +++ b/pygeoweaver/list_workflows.py @@ -1,6 +1,6 @@ - +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir def list_workflows(): - - pass - + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--workflow"], cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/main.py b/pygeoweaver/main.py deleted file mode 100644 index 792b612..0000000 --- a/pygeoweaver/main.py +++ /dev/null @@ -1,14 +0,0 @@ -""" -The main function of pygeoweaver -To run in CLI mode. -""" -from server import start, stop - -def main(): - # start geoweaver - #start() - # stop geoweaver - stop() - -if __name__ == "__main__": - main() diff --git a/pygeoweaver/run_process.py b/pygeoweaver/run_process.py new file mode 100644 index 0000000..6e681b8 --- /dev/null +++ b/pygeoweaver/run_process.py @@ -0,0 +1,10 @@ +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir + + +def run_process(host_id): + if not host_id: + raise RuntimeError("Host id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "process", f"--host-id={host_id}"], + cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/run_workflow.py b/pygeoweaver/run_workflow.py index eec8be1..84f1d93 100644 --- a/pygeoweaver/run_workflow.py +++ b/pygeoweaver/run_workflow.py @@ -1,6 +1,30 @@ +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - -def run_workflow(workflow_id, host_id, env_id, password_list): - print("Run workflow: ") - pass \ No newline at end of file +def run_worklfow(workflow_id, workflow_folder_path, workflow_zip_file_path, environments, hosts, passwords): + """ + Missing required parameter: '' + 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 + -f, --workflow-zip-file-path= + workflow package or path to workflow zip to run + -h, --hosts= hosts to run on + -p, --passwords= passwords to the target hosts + """ + if not workflow_id: + raise RuntimeError("Workflow id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, + "-d", workflow_folder_path, + "-e", environments, + "-f", workflow_zip_file_path, + "-h", hosts, + "-p", passwords], + cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/server.py b/pygeoweaver/server.py index 5a6fe1b..96220ad 100644 --- a/pygeoweaver/server.py +++ b/pygeoweaver/server.py @@ -1,6 +1,6 @@ import os import subprocess -from utils import get_root_dir +from pygeoweaver.utils import get_root_dir """ This module provides function to start and stop Geoweaver server. diff --git a/pygeoweaver/start.sh b/pygeoweaver/start.sh index a3ee485..e5df1c5 100755 --- a/pygeoweaver/start.sh +++ b/pygeoweaver/start.sh @@ -3,14 +3,7 @@ echo "Stop running Geoweaver if any.." pkill -f geoweaver -FILE=~/geoweaver.jar -if [ -f "$FILE" ]; then - echo "$FILE exists. Remove.." - rm -f $FILE -fi -echo "Downloading the latest geoweaver.jar to user home directory" -cd ~ && curl -OL https://github.com/ESIPFed/Geoweaver/releases/download/latest/geoweaver.jar echo "Start Geoweaver.." nohup java -jar ~/geoweaver.jar > ~/geoweaver.log & diff --git a/pygeoweaver/utils.py b/pygeoweaver/utils.py index 79c818f..79ffb71 100644 --- a/pygeoweaver/utils.py +++ b/pygeoweaver/utils.py @@ -1,6 +1,36 @@ import os +import subprocess +import requests + +def get_home_dir(): + return os.path.expanduser('~') def get_root_dir(): - print(os.path.basename(__file__)) head, tail = os.path.split(__file__) - return head \ No newline at end of file + return head + +def get_geoweaver_jar_path(): + return f"{get_home_dir()}/geoweaver.jar" + +def check_geoweaver_jar(): + return os.path.isfile(get_geoweaver_jar_path()) + +def download_geoweaver_jar(overwrite=False): + if check_geoweaver_jar(): + if overwrite: + os.remove(get_geoweaver_jar_path()) + else: + subprocess.run(["chmod", "+x", get_geoweaver_jar_path()], cwd=f"{get_root_dir()}/") + return + + geoweaver_url = "https://github.com/ESIPFed/Geoweaver/releases/download/latest/geoweaver.jar" + r = requests.get(geoweaver_url) + + with open(get_geoweaver_jar_path(),'wb') as f: + f.write(r.content) + + if check_geoweaver_jar(): + print("Geoweaver.jar is downloaded") + + else: + raise RuntimeError("Fail to download geoweaver.jar") From 5e242d5f221c35fe38351a57dfd2c819d0803165 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Tue, 11 Apr 2023 19:13:01 -0400 Subject: [PATCH 04/27] ignore pyc --- .gitignore | 3 ++- pygeoweaver/__main__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 70c1748..f8f7537 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/* dist/* -*egg-info* \ No newline at end of file +*egg-info* +*.pyc diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py index 030339c..0608395 100644 --- a/pygeoweaver/__main__.py +++ b/pygeoweaver/__main__.py @@ -18,7 +18,7 @@ def main(): #list_processes() #list_workflows() # show history - show_process_history("xxx") + show_process_history("gfvnp8a7rgh") if __name__ == "__main__": From 9a5b53ca3af4654cbf046e44da844509b2a3398e Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 03:21:32 -0400 Subject: [PATCH 05/27] do not expose utils.py directly to import --- example.ipynb | 36 +++++++++++++++++++++++++++++++++++ poetry.lock | 23 ++++++++++++++++++++++ pygeoweaver/__init__.py | 15 +++++++++++++++ pygeoweaver/__main__.py | 9 +++++---- pygeoweaver/list_workflows.py | 3 ++- pygeoweaver/utils.py | 15 ++++++++++----- pyproject.toml | 12 ++++++++++++ 7 files changed, 103 insertions(+), 10 deletions(-) create mode 100644 example.ipynb create mode 100644 poetry.lock diff --git a/example.ipynb b/example.ipynb new file mode 100644 index 0000000..23f2265 --- /dev/null +++ b/example.ipynb @@ -0,0 +1,36 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "from pygeoweaver import utils" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..0b4d443 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,23 @@ +# This file is automatically @generated by Poetry and should not be changed by hand. + +[[package]] +name = "setuptools" +version = "67.6.1" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "setuptools-67.6.1-py3-none-any.whl", hash = "sha256:e728ca814a823bf7bf60162daf9db95b93d532948c4c0bea762ce62f60189078"}, + {file = "setuptools-67.6.1.tar.gz", hash = "sha256:257de92a9d50a60b8e22abfcbb771571fde0dbf3ec234463212027a4eeecbe9a"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + +[metadata] +lock-version = "2.0" +python-versions = ">=3.7" +content-hash = "68c684286894d37fcd564513438c52a08d07f432c936ad7a723a94128ec17a05" diff --git a/pygeoweaver/__init__.py b/pygeoweaver/__init__.py index e69de29..e654503 100644 --- a/pygeoweaver/__init__.py +++ b/pygeoweaver/__init__.py @@ -0,0 +1,15 @@ +# export only the specified functions + +__all__ = [ + 'detail_host', + 'detail_process', + 'detail_workflow', + 'export_workflow', + 'history_process', + 'history_workflow', + 'import_workflow', + 'list_hosts', + 'list_workflows', + 'list_processes', + 'server' +] diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py index 0608395..e445d9e 100644 --- a/pygeoweaver/__main__.py +++ b/pygeoweaver/__main__.py @@ -8,15 +8,16 @@ from pygeoweaver.list_workflows import list_workflows from pygeoweaver.server import start, stop + def main(): # start geoweaver - #start() + # start() # stop geoweaver # stop() # list resources - #list_hosts() - #list_processes() - #list_workflows() + # list_hosts() + # list_processes() + # list_workflows() # show history show_process_history("gfvnp8a7rgh") diff --git a/pygeoweaver/list_workflows.py b/pygeoweaver/list_workflows.py index 5a96d44..0078c3e 100644 --- a/pygeoweaver/list_workflows.py +++ b/pygeoweaver/list_workflows.py @@ -1,6 +1,7 @@ import subprocess from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir + def list_workflows(): download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--workflow"], cwd=f"{get_root_dir()}/") \ No newline at end of file + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--workflow"], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/utils.py b/pygeoweaver/utils.py index 79ffb71..cc1b97a 100644 --- a/pygeoweaver/utils.py +++ b/pygeoweaver/utils.py @@ -2,19 +2,24 @@ import subprocess import requests + def get_home_dir(): return os.path.expanduser('~') + def get_root_dir(): head, tail = os.path.split(__file__) return head + def get_geoweaver_jar_path(): return f"{get_home_dir()}/geoweaver.jar" + def check_geoweaver_jar(): return os.path.isfile(get_geoweaver_jar_path()) + def download_geoweaver_jar(overwrite=False): if check_geoweaver_jar(): if overwrite: @@ -22,15 +27,15 @@ def download_geoweaver_jar(overwrite=False): else: subprocess.run(["chmod", "+x", get_geoweaver_jar_path()], cwd=f"{get_root_dir()}/") return - + geoweaver_url = "https://github.com/ESIPFed/Geoweaver/releases/download/latest/geoweaver.jar" r = requests.get(geoweaver_url) - - with open(get_geoweaver_jar_path(),'wb') as f: + + with open(get_geoweaver_jar_path(), 'wb') as f: f.write(r.content) - + if check_geoweaver_jar(): print("Geoweaver.jar is downloaded") - + else: raise RuntimeError("Fail to download geoweaver.jar") diff --git a/pyproject.toml b/pyproject.toml index 42d719d..2767b4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,4 +20,16 @@ classifiers = [ [project.urls] "Homepage" = "https://github.com/ESIPFed/pygeoweaver" +[tool.poetry] +name = "pygeoweaver" +version = "0.6.0" +description = "This is a wrapper package of the Geoweaver app." +authors = ["Geoweaver team "] +readme = "README.md" +homepage = "https://github.com/ESIPFed/pygeoweaver" + +[tool.poetry.dependencies] +python = ">=3.7" +setuptools = ">=61.0" +[tool.poetry.scripts] From 339db331fd670512425c58166432a42ce87a3b08 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 03:22:01 -0400 Subject: [PATCH 06/27] do not expose utils.py directly to import --- .idea/.gitignore | 8 ++++++++ .idea/inspectionProfiles/Project_Default.xml | 13 +++++++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/pygeoweaver.iml | 10 ++++++++++ .idea/vcs.xml | 6 ++++++ 7 files changed, 55 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/pygeoweaver.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..81cffca --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..05ef200 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e22b41a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/pygeoweaver.iml b/.idea/pygeoweaver.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/pygeoweaver.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From b5eaa71f9ae57811f42ba475af59ba40f207951d Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 03:24:34 -0400 Subject: [PATCH 07/27] remove .idea files --- .gitignore | 1 + .idea/.gitignore | 8 -------- .idea/inspectionProfiles/Project_Default.xml | 13 ------------- .idea/inspectionProfiles/profiles_settings.xml | 6 ------ .idea/misc.xml | 4 ---- .idea/modules.xml | 8 -------- .idea/pygeoweaver.iml | 10 ---------- .idea/vcs.xml | 6 ------ 8 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/pygeoweaver.iml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index f8f7537..6bf78b4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/* dist/* *egg-info* *.pyc +.idea/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 81cffca..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 05ef200..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index e22b41a..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/pygeoweaver.iml b/.idea/pygeoweaver.iml deleted file mode 100644 index 74d515a..0000000 --- a/.idea/pygeoweaver.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 0bfe09ca1f4a65d4d5eb479964337c0e412d3f12 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 03:45:55 -0400 Subject: [PATCH 08/27] fix import structure --- example.ipynb | 61 +++++++++++++++++++++++++++++++++++++---- pygeoweaver/__init__.py | 13 +++++++++ 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/example.ipynb b/example.ipynb index 23f2265..e856892 100644 --- a/example.ipynb +++ b/example.ipynb @@ -2,14 +2,63 @@ "cells": [ { "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, + "execution_count": 7, "outputs": [], "source": [ - "from pygeoweaver import utils" - ] + "import pygeoweaver" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "start_time": "2023-04-15T03:38:58.622770Z", + "end_time": "2023-04-15T03:38:58.629684Z" + } + } + }, + { + "cell_type": "markdown", + "source": [ + "## List hosts" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 8, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'module' object is not callable", + "output_type": "error", + "traceback": [ + "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", + "\u001B[0;31mTypeError\u001B[0m Traceback (most recent call last)", + "Cell \u001B[0;32mIn[8], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[43mpygeoweaver\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mlist_hosts\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n", + "\u001B[0;31mTypeError\u001B[0m: 'module' object is not callable" + ] + } + ], + "source": [ + "pygeoweaver.list_hosts()" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "start_time": "2023-04-15T03:38:17.417330Z", + "end_time": "2023-04-15T03:38:20.385717Z" + } + } + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [], + "metadata": { + "collapsed": false + } } ], "metadata": { diff --git a/pygeoweaver/__init__.py b/pygeoweaver/__init__.py index e654503..1bae7df 100644 --- a/pygeoweaver/__init__.py +++ b/pygeoweaver/__init__.py @@ -1,5 +1,18 @@ +from list_hosts import list_hosts +from server import start, stop, download_geoweaver +from history_process import show_process_history as history_process +from pygeoweaver.detail_host import detail_host +from detail_process import detail_process +from detail_workflow import detail_workflow +from export_workflow import export_worklfow +from list_workflows import list_workflows +from list_processes import list_processes +from history_workflow import show_workflow_history as history_workflow + + # export only the specified functions + __all__ = [ 'detail_host', 'detail_process', From 35933258a7b59da6e872c61c3e48bcad4575cb2c Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 04:28:50 -0400 Subject: [PATCH 09/27] fix typo --- example.ipynb | 48 ++++++++++++++++++++++++++++------ pygeoweaver/__init__.py | 18 ++++++------- pygeoweaver/export_workflow.py | 2 +- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/example.ipynb b/example.ipynb index e856892..94534fe 100644 --- a/example.ipynb +++ b/example.ipynb @@ -2,16 +2,48 @@ "cells": [ { "cell_type": "code", - "execution_count": 7, - "outputs": [], + "execution_count": 30, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Found existing installation: pygeoweaver 0.6.0\r\n", + "Not uninstalling pygeoweaver at /Users/gokulprathin/PycharmProjects/pygeoweaver, outside environment /Users/gokulprathin/PycharmProjects/pygeoweaver/venv\r\n", + "Can't uninstall 'pygeoweaver'. No files were found to uninstall.\r\n", + "Obtaining file:///Users/gokulprathin/PycharmProjects/pygeoweaver\r\n", + " Installing build dependencies ... \u001B[?25ldone\r\n", + "\u001B[?25h Checking if build backend supports build_editable ... \u001B[?25ldone\r\n", + "\u001B[?25h Getting requirements to build editable ... \u001B[?25ldone\r\n", + "\u001B[?25h Installing backend dependencies ... \u001B[?25ldone\r\n", + "\u001B[?25h Preparing editable metadata (pyproject.toml) ... \u001B[?25ldone\r\n", + "\u001B[?25hBuilding wheels for collected packages: pygeoweaver\r\n", + " Building editable for pygeoweaver (pyproject.toml) ... \u001B[?25ldone\r\n", + "\u001B[?25h Created wheel for pygeoweaver: filename=pygeoweaver-0.6.0-0.editable-py3-none-any.whl size=4008 sha256=5d11b0e13b3cbcef560b3f820638f7435fdb4b5c436b0ff50ebecfb9b10e14ee\r\n", + " Stored in directory: /private/var/folders/lw/rt7qqd6s6h5198mg2b6dlqlr0000gn/T/pip-ephem-wheel-cache-76m1206k/wheels/1a/77/17/d6f45e73d8d28da6dbaaee5486a02eeacc14363272575b56bb\r\n", + "Successfully built pygeoweaver\r\n", + "Installing collected packages: pygeoweaver\r\n", + " Attempting uninstall: pygeoweaver\r\n", + " Found existing installation: pygeoweaver 0.6.0\r\n", + " Not uninstalling pygeoweaver at /Users/gokulprathin/PycharmProjects/pygeoweaver, outside environment /Users/gokulprathin/PycharmProjects/pygeoweaver/venv\r\n", + " Can't uninstall 'pygeoweaver'. No files were found to uninstall.\r\n", + "Successfully installed pygeoweaver-0.6.0\r\n", + "\r\n", + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m23.0.1\u001B[0m\r\n", + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\r\n" + ] + } + ], "source": [ + "!pip3 uninstall pygeoweaver\n", + "!pip3 install -e .\n", "import pygeoweaver" ], "metadata": { "collapsed": false, "ExecuteTime": { - "start_time": "2023-04-15T03:38:58.622770Z", - "end_time": "2023-04-15T03:38:58.629684Z" + "start_time": "2023-04-15T03:55:20.875274Z", + "end_time": "2023-04-15T03:55:24.431925Z" } } }, @@ -26,7 +58,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 31, "outputs": [ { "ename": "TypeError", @@ -35,7 +67,7 @@ "traceback": [ "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", "\u001B[0;31mTypeError\u001B[0m Traceback (most recent call last)", - "Cell \u001B[0;32mIn[8], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[43mpygeoweaver\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mlist_hosts\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n", + "Cell \u001B[0;32mIn[31], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[43mpygeoweaver\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mlist_hosts\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n", "\u001B[0;31mTypeError\u001B[0m: 'module' object is not callable" ] } @@ -46,8 +78,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "start_time": "2023-04-15T03:38:17.417330Z", - "end_time": "2023-04-15T03:38:20.385717Z" + "start_time": "2023-04-15T03:51:52.978958Z", + "end_time": "2023-04-15T03:51:52.991233Z" } } }, diff --git a/pygeoweaver/__init__.py b/pygeoweaver/__init__.py index 1bae7df..6a18cb4 100644 --- a/pygeoweaver/__init__.py +++ b/pygeoweaver/__init__.py @@ -1,13 +1,13 @@ -from list_hosts import list_hosts -from server import start, stop, download_geoweaver -from history_process import show_process_history as history_process +from pygeoweaver.list_hosts import list_hosts +from pygeoweaver.server import start, stop, download_geoweaver +from pygeoweaver.history_process import show_process_history as history_process from pygeoweaver.detail_host import detail_host -from detail_process import detail_process -from detail_workflow import detail_workflow -from export_workflow import export_worklfow -from list_workflows import list_workflows -from list_processes import list_processes -from history_workflow import show_workflow_history as history_workflow +from pygeoweaver.detail_process import detail_process +from pygeoweaver.detail_workflow import detail_workflow +from pygeoweaver.export_workflow import export_workflow +from pygeoweaver.list_workflows import list_workflows +from pygeoweaver.list_processes import list_processes +from pygeoweaver.history_workflow import show_workflow_history as history_workflow # export only the specified functions diff --git a/pygeoweaver/export_workflow.py b/pygeoweaver/export_workflow.py index 7a10df7..163e742 100644 --- a/pygeoweaver/export_workflow.py +++ b/pygeoweaver/export_workflow.py @@ -2,7 +2,7 @@ from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir -def export_worklfow(workflow_id, mode, target_file_path): +def export_workflow(workflow_id, mode, target_file_path): """ Usage:
export workflow [--mode=] From f6c79e3a394a8b1dd1c5fd4f85a76fb0526a7ae8 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 04:30:20 -0400 Subject: [PATCH 10/27] updated example.ipynb --- example.ipynb | 335 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 281 insertions(+), 54 deletions(-) diff --git a/example.ipynb b/example.ipynb index 94534fe..d3f2fd2 100644 --- a/example.ipynb +++ b/example.ipynb @@ -2,55 +2,85 @@ "cells": [ { "cell_type": "code", - "execution_count": 30, + "execution_count": 6, + "id": "511fe880", + "metadata": {}, + "outputs": [], + "source": [ + "import pygeoweaver" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## List Hosts" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "b655ecc6", + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Found existing installation: pygeoweaver 0.6.0\r\n", - "Not uninstalling pygeoweaver at /Users/gokulprathin/PycharmProjects/pygeoweaver, outside environment /Users/gokulprathin/PycharmProjects/pygeoweaver/venv\r\n", - "Can't uninstall 'pygeoweaver'. No files were found to uninstall.\r\n", - "Obtaining file:///Users/gokulprathin/PycharmProjects/pygeoweaver\r\n", - " Installing build dependencies ... \u001B[?25ldone\r\n", - "\u001B[?25h Checking if build backend supports build_editable ... \u001B[?25ldone\r\n", - "\u001B[?25h Getting requirements to build editable ... \u001B[?25ldone\r\n", - "\u001B[?25h Installing backend dependencies ... \u001B[?25ldone\r\n", - "\u001B[?25h Preparing editable metadata (pyproject.toml) ... \u001B[?25ldone\r\n", - "\u001B[?25hBuilding wheels for collected packages: pygeoweaver\r\n", - " Building editable for pygeoweaver (pyproject.toml) ... \u001B[?25ldone\r\n", - "\u001B[?25h Created wheel for pygeoweaver: filename=pygeoweaver-0.6.0-0.editable-py3-none-any.whl size=4008 sha256=5d11b0e13b3cbcef560b3f820638f7435fdb4b5c436b0ff50ebecfb9b10e14ee\r\n", - " Stored in directory: /private/var/folders/lw/rt7qqd6s6h5198mg2b6dlqlr0000gn/T/pip-ephem-wheel-cache-76m1206k/wheels/1a/77/17/d6f45e73d8d28da6dbaaee5486a02eeacc14363272575b56bb\r\n", - "Successfully built pygeoweaver\r\n", - "Installing collected packages: pygeoweaver\r\n", - " Attempting uninstall: pygeoweaver\r\n", - " Found existing installation: pygeoweaver 0.6.0\r\n", - " Not uninstalling pygeoweaver at /Users/gokulprathin/PycharmProjects/pygeoweaver, outside environment /Users/gokulprathin/PycharmProjects/pygeoweaver/venv\r\n", - " Can't uninstall 'pygeoweaver'. No files were found to uninstall.\r\n", - "Successfully installed pygeoweaver-0.6.0\r\n", - "\r\n", - "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m23.0.1\u001B[0m\r\n", - "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\r\n" + "+---------+-----------+-----------------+------+------------+\n", + "| Host Id | Hostname | IP | Port | Username |\n", + "+---------+-----------+-----------------+------+------------+\n", + "| 2c9z4s | Local | | | - |\n", + "| 100001 | Localhost | 127.0.0.1 | 22 | publicuser |\n", + "| 3yvozx | New Host | | | - |\n", + "| jf7wuu | Remote | 129.174.131.229 | 22 | chetana |\n", + "+---------+-----------+-----------------+------+------------+\n" ] } ], "source": [ - "!pip3 uninstall pygeoweaver\n", - "!pip3 install -e .\n", - "import pygeoweaver" + "pygeoweaver.list_hosts()" + ] + }, + { + "cell_type": "markdown", + "source": [ + "## Start server" ], "metadata": { - "collapsed": false, - "ExecuteTime": { - "start_time": "2023-04-15T03:55:20.875274Z", - "end_time": "2023-04-15T03:55:24.431925Z" + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 8, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "start Geoweaver instance..\n", + "Stop running Geoweaver if any..\n", + "Start Geoweaver..\n", + "GeoWeaver is started and ready for use..\n", + "URL: http://localhost:8070/Geoweaver\n", + "Success: Geoweaver is up\n" + ] } + ], + "source": [ + "pygeoweaver.start()" + ], + "metadata": { + "collapsed": false } }, { "cell_type": "markdown", "source": [ - "## List hosts" + "## Show a specific host detail" ], "metadata": { "collapsed": false @@ -58,36 +88,233 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 11, "outputs": [ { - "ename": "TypeError", - "evalue": "'module' object is not callable", - "output_type": "error", - "traceback": [ - "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", - "\u001B[0;31mTypeError\u001B[0m Traceback (most recent call last)", - "Cell \u001B[0;32mIn[31], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[43mpygeoweaver\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mlist_hosts\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\n", - "\u001B[0;31mTypeError\u001B[0m: 'module' object is not callable" + "name": "stdout", + "output_type": "stream", + "text": [ + "HostId: 100001\n", + "+---------+-----------+-----------+------+------------+--------+------+-------------------+---------------+\n", + "| Host Id | Hostname | IP | Port | Username | Owner | type | url | Confidential? |\n", + "+---------+-----------+-----------+------+------------+--------+------+-------------------+---------------+\n", + "| 100001 | Localhost | 127.0.0.1 | 22 | publicuser | 111111 | ssh | http://localhost/ | FALSE |\n", + "+---------+-----------+-----------+------+------------+--------+------+-------------------+---------------+\n" ] } ], "source": [ - "pygeoweaver.list_hosts()" + "pygeoweaver.detail_host('100001')" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## List workflows" ], "metadata": { - "collapsed": false, - "ExecuteTime": { - "start_time": "2023-04-15T03:51:52.978958Z", - "end_time": "2023-04-15T03:51:52.991233Z" + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 13, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "+-----------------------+----------------------+\n", + "| Workflow Id | Name |\n", + "+-----------------------+----------------------+\n", + "| gr3ykr8dynu12vrwq11oy | snowcast_wormhole500 |\n", + "| ejthsf0nkll1ccdvvssg | test new |\n", + "| grlgu9mkbry3qe8qxdg1 | tada |\n", + "+-----------------------+----------------------+\n" + ] } + ], + "source": [ + "pygeoweaver.list_workflows()" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## Show details of a specific workflow" + ], + "metadata": { + "collapsed": false } }, { "cell_type": "code", - "execution_count": null, - "outputs": [], - "source": [], + "execution_count": 14, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WorkflowId: gr3ykr8dynu12vrwq11oy\n", + "+-----------------------+----------------------+-------------------------------------------------------------------------------------------------+--------+---------------+\n", + "| Workflow Id | Name | Description | Owner | Confidential? |\n", + "+-----------------------+----------------------+-------------------------------------------------------------------------------------------------+--------+---------------+\n", + "| gr3ykr8dynu12vrwq11oy | snowcast_wormhole500 | The complete workflow for snowcast workflow creation, train, test, validation, deploy, predict. | 111111 | FALSE |\n", + "+-----------------------+----------------------+-------------------------------------------------------------------------------------------------+--------+---------------+\n" + ] + } + ], + "source": [ + "pygeoweaver.detail_workflow('gr3ykr8dynu12vrwq11oy')" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## Show a specific workflow history" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 18, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "+-------------+---------+---------------------+---------------------+---------------+---------+-------+\n", + "| History Id | Status | Begin Time | End Time | Input | Output | Notes |\n", + "+-------------+---------+---------------------+---------------------+---------------+---------+-------+\n", + "| 5lwj8tt9wl6 | Stopped | 03/08/2023 04:47:10 | 03/08/2023 04:47:45 | No code saved | Skipped | - |\n", + "+-------------+---------+---------------------+---------------------+---------------+---------+-------+\n" + ] + } + ], + "source": [ + "pygeoweaver.history_workflow('5lwj8tt9wl6')" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## List Processes" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 19, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "+------------+-------------------------------------+----------+-------------+\n", + "| Process Id | Name | Language | Description |\n", + "+------------+-------------------------------------+----------+-------------+\n", + "| 8orlpp | sample bash | shell | shell |\n", + "| rfgoeg | current_dir | python | - |\n", + "| de8djk | sample-bash | shell | shell |\n", + "| 78vedq | data_sentinel2 | python | - |\n", + "| mxpyqt | model_creation_lstm | python | python |\n", + "| c2xkhz | model_creation_rf | python | - |\n", + "| rauqsh | model_creation_ghostnet | python | python |\n", + "| mi3e5n | model_comparison | python | - |\n", + "| u7xh2p | data_integration | python | - |\n", + "| 2wkl6e | service_deployment | python | python |\n", + "| i2fynz | service_prediction | python | - |\n", + "| e8k4wq | model_train_validate | python | - |\n", + "| h1qp9v | model_test | python | - |\n", + "| urd0nk | data_terrainFeatures | python | - |\n", + "| 525l8q | data_gee_modis_station_only | python | - |\n", + "| 7temiv | data_gee_sentinel1_station_only | python | - |\n", + "| rmxece | data_associate_station_grid_cell | python | - |\n", + "| illwc1 | data_gee_modis_real_time | python | - |\n", + "| sjs5by | data_gee_sentinel1_real_time | python | - |\n", + "| y7nb46 | base_hole | python | - |\n", + "| a8p3n7 | data_gee_gridmet_station_only | python | - |\n", + "| smsdr0 | data_gee_gridmet_real_time | python | - |\n", + "| 4i0sop | model_creation_xgboost | python | - |\n", + "| b63prf | testing_data_integration | python | - |\n", + "| zh38b6 | snowcast_utils | python | - |\n", + "| wdh394 | model_create_kehan | python | - |\n", + "| p87wh1 | data_snotel_real_time | python | - |\n", + "| ilbqzg | all_dependencies | python | - |\n", + "| do86ae | data_WUS_UCLA_SR | python | python |\n", + "| gkhtc0 | data_nsidc_4km_swe | python | - |\n", + "| lbd6cp | model_creation_et | python | python |\n", + "| 8ovvln | data_nsidc_4km_swe_testing | python | - |\n", + "| 6z5it4 | install_dependencies | python | - |\n", + "| 2l4pid | interpreter-exec | python | python |\n", + "| vzrekq | plot_utilities | python | - |\n", + "| 2u9n3d | subglacial_topography_plot | python | - |\n", + "| oikovr | gridded_topography_plot | python | - |\n", + "| r5qlro | normal_score_transformation | python | - |\n", + "| hyf9o1 | transformed_data_plot | python | python |\n", + "| a9jrs1 | isotropic_experimental_variogram | python | - |\n", + "| 8hyi80 | anisotropoic_experimental_variogram | python | - |\n", + "| 0qutu4 | plot_test | jupyter | jupyter |\n", + "| 8sv3o6 | gridmet_region_selection_download | python | python |\n", + "| 11iolq | gridmet_modis | python | python |\n", + "+------------+-------------------------------------+----------+-------------+\n" + ] + } + ], + "source": [ + "pygeoweaver.list_processes()" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "markdown", + "source": [ + "## Show history of a specific process" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 23, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "+--------------+--------+---------------------+---------------------+--------------------------------------------------------------------+------------------------------------------------+-------+\n", + "| History Id | Status | Begin Time | End Time | Input | Output | Notes |\n", + "+--------------+--------+---------------------+---------------------+--------------------------------------------------------------------+------------------------------------------------+-------+\n", + "| jbt9iT3SfNdf | Done | 02/28/2023 05:41:56 | 02/28/2023 05:41:57 | import os\n", + "\n", + "print(str(os.path.dirname(os.path.realpath(__file__)))) | /Users/gokulprathin/gw-workspace/jbt9iT3SfNdf\n", + " | - |\n", + "+--------------+--------+---------------------+---------------------+--------------------------------------------------------------------+------------------------------------------------+-------+\n" + ] + } + ], + "source": [ + "pygeoweaver.history_process('jbt9iT3SfNdf')" + ], "metadata": { "collapsed": false } @@ -95,23 +322,23 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.6" + "pygments_lexer": "ipython3", + "version": "3.9.16" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 5 } From c20e1dfdc5d301d839bddf138652284e6ef9ff24 Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 04:32:29 -0400 Subject: [PATCH 11/27] refactor --- pygeoweaver/__main__.py | 42 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py index e445d9e..d576876 100644 --- a/pygeoweaver/__main__.py +++ b/pygeoweaver/__main__.py @@ -2,25 +2,29 @@ The main function of pygeoweaver To run in CLI mode. """ -from pygeoweaver.history_process import show_process_history -from pygeoweaver.list_hosts import list_hosts -from pygeoweaver.list_processes import list_processes -from pygeoweaver.list_workflows import list_workflows -from pygeoweaver.server import start, stop +# replaced with __init__.py -def main(): - # start geoweaver - # start() - # stop geoweaver - # stop() - # list resources - # list_hosts() - # list_processes() - # list_workflows() - # show history - show_process_history("gfvnp8a7rgh") - -if __name__ == "__main__": - main() +# from pygeoweaver.history_process import show_process_history +# from pygeoweaver.list_hosts import list_hosts +# from pygeoweaver.list_processes import list_processes +# from pygeoweaver.list_workflows import list_workflows +# from pygeoweaver.server import start, stop +# +# +# def main(): +# # start geoweaver +# # start() +# # stop geoweaver +# # stop() +# # list resources +# # list_hosts() +# # list_processes() +# # list_workflows() +# # show history +# show_process_history("gfvnp8a7rgh") +# +# +# if __name__ == "__main__": +# main() From 5046fe3928cd5041298316a9a8bcde8cbe2db21f Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 17:04:14 -0400 Subject: [PATCH 12/27] fix run process --- pygeoweaver/__init__.py | 7 +++++-- pygeoweaver/run_process.py | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pygeoweaver/__init__.py b/pygeoweaver/__init__.py index 6a18cb4..319cbe1 100644 --- a/pygeoweaver/__init__.py +++ b/pygeoweaver/__init__.py @@ -1,4 +1,6 @@ from pygeoweaver.list_hosts import list_hosts +from pygeoweaver.run_process import run_process +from pygeoweaver.run_workflow import run_worklfow from pygeoweaver.server import start, stop, download_geoweaver from pygeoweaver.history_process import show_process_history as history_process from pygeoweaver.detail_host import detail_host @@ -9,7 +11,6 @@ from pygeoweaver.list_processes import list_processes from pygeoweaver.history_workflow import show_workflow_history as history_workflow - # export only the specified functions @@ -24,5 +25,7 @@ 'list_hosts', 'list_workflows', 'list_processes', - 'server' + 'server', + 'run_process', + 'run_workflow' ] diff --git a/pygeoweaver/run_process.py b/pygeoweaver/run_process.py index 6e681b8..97698bd 100644 --- a/pygeoweaver/run_process.py +++ b/pygeoweaver/run_process.py @@ -2,9 +2,10 @@ from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir -def run_process(host_id): +def run_process(*, process_id, host_id, password, environment): if not host_id: raise RuntimeError("Host id is missing") download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "process", f"--host-id={host_id}"], - cwd=f"{get_root_dir()}/") \ No newline at end of file + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "process", f"--host={host_id}", + f"--password={password}", f"--environment={environment}", process_id], + cwd=f"{get_root_dir()}/") From 62b411f864e708efd5e1b4e11188ff93b673ca9a Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sat, 15 Apr 2023 17:28:01 -0400 Subject: [PATCH 13/27] fix run workflow --- pygeoweaver/run_workflow.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/pygeoweaver/run_workflow.py b/pygeoweaver/run_workflow.py index 84f1d93..5fcaa9d 100644 --- a/pygeoweaver/run_workflow.py +++ b/pygeoweaver/run_workflow.py @@ -2,7 +2,7 @@ from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir -def run_worklfow(workflow_id, workflow_folder_path, workflow_zip_file_path, environments, hosts, passwords): +def run_worklfow(*, workflow_id, workflow_folder_path, workflow_zip_file_path, environments, host, password): """ Missing required parameter: '' Usage:
run workflow [-d=] @@ -18,13 +18,26 @@ def run_worklfow(workflow_id, workflow_folder_path, workflow_zip_file_path, envi -h, --hosts= hosts to run on -p, --passwords= passwords to the target hosts """ - if not workflow_id: - raise RuntimeError("Workflow id is missing") download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, - "-d", workflow_folder_path, - "-e", environments, - "-f", workflow_zip_file_path, - "-h", hosts, - "-p", passwords], - cwd=f"{get_root_dir()}/") \ No newline at end of file + + if workflow_folder_path and workflow_zip_file_path: + raise RuntimeError("Please provide either Folder path or Zip path") + + if workflow_folder_path and not workflow_zip_file_path: + # command to run workflow from folder + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, + "-d", workflow_folder_path, + "-e", environments, + "-h", host, + "-p", password], + cwd=f"{get_root_dir()}/") + + if not workflow_folder_path and workflow_zip_file_path: + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "workflow", workflow_id, + "-e", environments, + "-f", workflow_zip_file_path, + "-h", host, + "-p", password], + cwd=f"{get_root_dir()}/") + + raise RuntimeError("Please provide either zip path or directory path to run workflow.") From ee087ee393b0cf8caaf64444334dcf542dfe1536 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 10:05:56 -0400 Subject: [PATCH 14/27] history doesn't need three --- pygeoweaver/__main__.py | 18 ++++++++++++++++-- pygeoweaver/export_workflow.py | 8 ++++---- pygeoweaver/history.py | 12 ++++++++++++ pygeoweaver/history_process.py | 9 --------- pygeoweaver/history_workflow.py | 9 --------- pygeoweaver/import_workflow.py | 4 ++-- 6 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 pygeoweaver/history.py delete mode 100644 pygeoweaver/history_process.py delete mode 100644 pygeoweaver/history_workflow.py diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py index 0608395..4014d20 100644 --- a/pygeoweaver/__main__.py +++ b/pygeoweaver/__main__.py @@ -2,7 +2,12 @@ The main function of pygeoweaver To run in CLI mode. """ -from pygeoweaver.history_process import show_process_history +from pygeoweaver.detail_host import detail_host +from pygeoweaver.detail_process import detail_process +from pygeoweaver.detail_workflow import detail_workflow +from pygeoweaver.export_workflow import export_worklfow +from pygeoweaver.history import show_history +from pygeoweaver.import_workflow import import_workflow from pygeoweaver.list_hosts import list_hosts from pygeoweaver.list_processes import list_processes from pygeoweaver.list_workflows import list_workflows @@ -18,7 +23,16 @@ def main(): #list_processes() #list_workflows() # show history - show_process_history("gfvnp8a7rgh") + #show_history("ll3u3W78eOEfklxhBJ") + # detail host + # detail_host("100001") + # detail process + # detail_process("7pxu8c") + #detail_workflow("5jnhcrq33znbu2mue9v2") + # import workflow + #import_workflow("/Users/joe/Downloads/gr3ykr8dynu12vrwq11oy.zip") + # export workflow + export_worklfow("gr3ykr8dynu12vrwq11oy", "4", "/Users/joe/Downloads/test_pygeoweaver_export.zip") if __name__ == "__main__": diff --git a/pygeoweaver/export_workflow.py b/pygeoweaver/export_workflow.py index 7a10df7..6c8bbbc 100644 --- a/pygeoweaver/export_workflow.py +++ b/pygeoweaver/export_workflow.py @@ -10,15 +10,15 @@ def export_worklfow(workflow_id, mode, target_file_path): target file path to save the workflow zip --mode= exportation model options: 1 - workflow only - 2 - workflow with process code + 2 - workflow with process code 3 - workflow with process code and only good history - 4 - workflow with process code and all the + 4 - workflow with process code and all the history.default option is 4. """ if not workflow_id: raise RuntimeError("Workflow id is missing") download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "export", "workflow", workflow_id, target_file_path, - "--mode", mode,], + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "export", "workflow", + f"--mode={mode}", workflow_id, target_file_path,], cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/history.py b/pygeoweaver/history.py new file mode 100644 index 0000000..e6bfec7 --- /dev/null +++ b/pygeoweaver/history.py @@ -0,0 +1,12 @@ +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir + + +def show_history(history_id): + """ + Workflow and process history uses the same method to check + """ + if not history_id: + raise RuntimeError("history id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "history", history_id], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/history_process.py b/pygeoweaver/history_process.py deleted file mode 100644 index d691ee5..0000000 --- a/pygeoweaver/history_process.py +++ /dev/null @@ -1,9 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - - -def show_process_history(process_history_id): - if not process_history_id: - raise RuntimeError("Process history id is missing") - download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "history", process_history_id], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/history_workflow.py b/pygeoweaver/history_workflow.py deleted file mode 100644 index 57c745b..0000000 --- a/pygeoweaver/history_workflow.py +++ /dev/null @@ -1,9 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - - -def show_workflow_history(workflow_history_id): - if not workflow_history_id: - raise RuntimeError("Workflow history id is missing") - download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "history", workflow_history_id], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/import_workflow.py b/pygeoweaver/import_workflow.py index ea112ec..e615e51 100644 --- a/pygeoweaver/import_workflow.py +++ b/pygeoweaver/import_workflow.py @@ -12,6 +12,6 @@ def import_workflow(workflow_zip_file_path): if not workflow_zip_file_path: raise RuntimeError("Workflow zip file path is missing") download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "import", "workflow", workflow_zip_file_path], - cwd=f"{get_root_dir()}/") + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "import", + "workflow", workflow_zip_file_path], cwd=f"{get_root_dir()}/") From 289208d2677e7b0d135c77ad141195d765399554 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 13:56:45 -0400 Subject: [PATCH 15/27] clean up __init__ --- .gitignore | 6 +++++- pygeoweaver/__init__.py | 31 ------------------------------- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 6bf78b4..94344a4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,8 @@ build/* dist/* *egg-info* *.pyc -.idea/ \ No newline at end of file +*/*.pyc +.idea/ +pygeoweaver/__pycache__/* +*.pyc +*.pyc diff --git a/pygeoweaver/__init__.py b/pygeoweaver/__init__.py index 319cbe1..e69de29 100644 --- a/pygeoweaver/__init__.py +++ b/pygeoweaver/__init__.py @@ -1,31 +0,0 @@ -from pygeoweaver.list_hosts import list_hosts -from pygeoweaver.run_process import run_process -from pygeoweaver.run_workflow import run_worklfow -from pygeoweaver.server import start, stop, download_geoweaver -from pygeoweaver.history_process import show_process_history as history_process -from pygeoweaver.detail_host import detail_host -from pygeoweaver.detail_process import detail_process -from pygeoweaver.detail_workflow import detail_workflow -from pygeoweaver.export_workflow import export_workflow -from pygeoweaver.list_workflows import list_workflows -from pygeoweaver.list_processes import list_processes -from pygeoweaver.history_workflow import show_workflow_history as history_workflow - -# export only the specified functions - - -__all__ = [ - 'detail_host', - 'detail_process', - 'detail_workflow', - 'export_workflow', - 'history_process', - 'history_workflow', - 'import_workflow', - 'list_hosts', - 'list_workflows', - 'list_processes', - 'server', - 'run_process', - 'run_workflow' -] From eebff7a9370b8f0821bcde02185cb272601c28a3 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 15:03:14 -0400 Subject: [PATCH 16/27] update ignore --- .gitignore | 2 +- pygeoweaver/__main__.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 94344a4..14edd43 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,6 @@ dist/* *.pyc */*.pyc .idea/ -pygeoweaver/__pycache__/* +*/__pycache__/* *.pyc *.pyc diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py index 970363e..16f4c5b 100644 --- a/pygeoweaver/__main__.py +++ b/pygeoweaver/__main__.py @@ -33,3 +33,7 @@ def main(): #import_workflow("/Users/joe/Downloads/gr3ykr8dynu12vrwq11oy.zip") # export workflow export_worklfow("gr3ykr8dynu12vrwq11oy", "4", "/Users/joe/Downloads/test_pygeoweaver_export.zip") + + +if __name__ == "__main__": + main() \ No newline at end of file From dda9df130bb53b921edcec0569120cf4b94dd8ce Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 15:42:52 -0400 Subject: [PATCH 17/27] refactor and remove duplication --- pygeoweaver/__main__.py | 18 +++++------- pygeoweaver/detail_host.py | 10 ------- pygeoweaver/detail_process.py | 10 ------- pygeoweaver/detail_workflow.py | 11 ------- pygeoweaver/list_hosts.py | 7 ----- pygeoweaver/list_processes.py | 7 ----- pygeoweaver/list_workflows.py | 7 ----- pygeoweaver/run_process.py | 11 ------- pygeoweaver/sc_detail.py | 29 +++++++++++++++++++ .../{export_workflow.py => sc_export.py} | 0 pygeoweaver/{history.py => sc_history.py} | 0 .../{import_workflow.py => sc_import.py} | 0 pygeoweaver/sc_list.py | 19 ++++++++++++ pygeoweaver/{run_workflow.py => sc_run.py} | 8 +++++ pyproject.toml | 2 +- setup.cfg | 6 ++++ 16 files changed, 70 insertions(+), 75 deletions(-) delete mode 100644 pygeoweaver/detail_host.py delete mode 100644 pygeoweaver/detail_process.py delete mode 100644 pygeoweaver/detail_workflow.py delete mode 100644 pygeoweaver/list_hosts.py delete mode 100644 pygeoweaver/list_processes.py delete mode 100644 pygeoweaver/list_workflows.py delete mode 100644 pygeoweaver/run_process.py create mode 100644 pygeoweaver/sc_detail.py rename pygeoweaver/{export_workflow.py => sc_export.py} (100%) rename pygeoweaver/{history.py => sc_history.py} (100%) rename pygeoweaver/{import_workflow.py => sc_import.py} (100%) create mode 100644 pygeoweaver/sc_list.py rename pygeoweaver/{run_workflow.py => sc_run.py} (83%) create mode 100644 setup.cfg diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py index 16f4c5b..6a5a9aa 100644 --- a/pygeoweaver/__main__.py +++ b/pygeoweaver/__main__.py @@ -2,15 +2,11 @@ The main function of pygeoweaver To run in CLI mode. """ -from pygeoweaver.detail_host import detail_host -from pygeoweaver.detail_process import detail_process -from pygeoweaver.detail_workflow import detail_workflow -from pygeoweaver.export_workflow import export_worklfow -from pygeoweaver.history import show_history -from pygeoweaver.import_workflow import import_workflow -from pygeoweaver.list_hosts import list_hosts -from pygeoweaver.list_processes import list_processes -from pygeoweaver.list_workflows import list_workflows +from pygeoweaver.sc_detail import detail_host, detail_process, detail_workflow +from pygeoweaver.sc_export import export_workflow +from pygeoweaver.sc_history import show_history +from pygeoweaver.sc_import import import_workflow +from pygeoweaver.sc_list import list_hosts, list_processes, list_workflows from pygeoweaver.server import start, stop def main(): @@ -21,7 +17,7 @@ def main(): # list resources #list_hosts() #list_processes() - #list_workflows() + list_workflows() # show history #show_history("ll3u3W78eOEfklxhBJ") # detail host @@ -32,7 +28,7 @@ def main(): # import workflow #import_workflow("/Users/joe/Downloads/gr3ykr8dynu12vrwq11oy.zip") # export workflow - export_worklfow("gr3ykr8dynu12vrwq11oy", "4", "/Users/joe/Downloads/test_pygeoweaver_export.zip") + export_workflow("gr3ykr8dynu12vrwq11oy", "4", "/Users/joe/Downloads/test_pygeoweaver_export.zip") if __name__ == "__main__": diff --git a/pygeoweaver/detail_host.py b/pygeoweaver/detail_host.py deleted file mode 100644 index 4d2733a..0000000 --- a/pygeoweaver/detail_host.py +++ /dev/null @@ -1,10 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - - -def detail_host(host_id): - if not host_id: - raise RuntimeError("Host id is missing") - download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "detail", f"--host-id={host_id}"], - cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/detail_process.py b/pygeoweaver/detail_process.py deleted file mode 100644 index 30f655a..0000000 --- a/pygeoweaver/detail_process.py +++ /dev/null @@ -1,10 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - - -def detail_process(process_id): - if not process_id: - raise RuntimeError("Process id is missing") - download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "detail", f"--process-id={process_id}"], - cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/detail_workflow.py b/pygeoweaver/detail_workflow.py deleted file mode 100644 index 64d57f8..0000000 --- a/pygeoweaver/detail_workflow.py +++ /dev/null @@ -1,11 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - - -def detail_workflow(workflow_id): - if not workflow_id: - raise RuntimeError("Workflow id is missing") - download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "detail", f"--workflow-id={workflow_id}"], - cwd=f"{get_root_dir()}/") - diff --git a/pygeoweaver/list_hosts.py b/pygeoweaver/list_hosts.py deleted file mode 100644 index a8f9ca7..0000000 --- a/pygeoweaver/list_hosts.py +++ /dev/null @@ -1,7 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - - -def list_hosts(): - download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--host"], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/list_processes.py b/pygeoweaver/list_processes.py deleted file mode 100644 index 3b7f6b0..0000000 --- a/pygeoweaver/list_processes.py +++ /dev/null @@ -1,7 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - -def list_processes(): - download_geoweaver_jar() - subprocess.run(["chmod", "+x", get_geoweaver_jar_path()], cwd=f"{get_root_dir()}/") - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--process"], cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/list_workflows.py b/pygeoweaver/list_workflows.py deleted file mode 100644 index 0078c3e..0000000 --- a/pygeoweaver/list_workflows.py +++ /dev/null @@ -1,7 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - - -def list_workflows(): - download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--workflow"], cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/run_process.py b/pygeoweaver/run_process.py deleted file mode 100644 index 97698bd..0000000 --- a/pygeoweaver/run_process.py +++ /dev/null @@ -1,11 +0,0 @@ -import subprocess -from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir - - -def run_process(*, process_id, host_id, password, environment): - if not host_id: - raise RuntimeError("Host id is missing") - download_geoweaver_jar() - subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "process", f"--host={host_id}", - f"--password={password}", f"--environment={environment}", process_id], - cwd=f"{get_root_dir()}/") diff --git a/pygeoweaver/sc_detail.py b/pygeoweaver/sc_detail.py new file mode 100644 index 0000000..21e5c9e --- /dev/null +++ b/pygeoweaver/sc_detail.py @@ -0,0 +1,29 @@ +""" +Detail subcommand +""" + +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir + + +def detail_workflow(workflow_id): + if not workflow_id: + raise RuntimeError("Workflow id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "detail", f"--workflow-id={workflow_id}"], + cwd=f"{get_root_dir()}/") + + +def detail_process(process_id): + if not process_id: + raise RuntimeError("Process id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "detail", f"--process-id={process_id}"], + cwd=f"{get_root_dir()}/") + +def detail_host(host_id): + if not host_id: + raise RuntimeError("Host id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "detail", f"--host-id={host_id}"], + cwd=f"{get_root_dir()}/") \ No newline at end of file diff --git a/pygeoweaver/export_workflow.py b/pygeoweaver/sc_export.py similarity index 100% rename from pygeoweaver/export_workflow.py rename to pygeoweaver/sc_export.py diff --git a/pygeoweaver/history.py b/pygeoweaver/sc_history.py similarity index 100% rename from pygeoweaver/history.py rename to pygeoweaver/sc_history.py diff --git a/pygeoweaver/import_workflow.py b/pygeoweaver/sc_import.py similarity index 100% rename from pygeoweaver/import_workflow.py rename to pygeoweaver/sc_import.py diff --git a/pygeoweaver/sc_list.py b/pygeoweaver/sc_list.py new file mode 100644 index 0000000..8b2c97a --- /dev/null +++ b/pygeoweaver/sc_list.py @@ -0,0 +1,19 @@ +import subprocess +from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir + + +def list_hosts(): + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--host"], cwd=f"{get_root_dir()}/") + + +def list_processes(): + download_geoweaver_jar() + subprocess.run(["chmod", "+x", get_geoweaver_jar_path()], cwd=f"{get_root_dir()}/") + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--process"], cwd=f"{get_root_dir()}/") + + +def list_workflows(): + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "list", "--workflow"], cwd=f"{get_root_dir()}/") + diff --git a/pygeoweaver/run_workflow.py b/pygeoweaver/sc_run.py similarity index 83% rename from pygeoweaver/run_workflow.py rename to pygeoweaver/sc_run.py index 5fcaa9d..f00f352 100644 --- a/pygeoweaver/run_workflow.py +++ b/pygeoweaver/sc_run.py @@ -2,6 +2,14 @@ from pygeoweaver.utils import download_geoweaver_jar, get_geoweaver_jar_path, get_root_dir +def run_process(*, process_id, host_id, password, environment): + if not host_id: + raise RuntimeError("Host id is missing") + download_geoweaver_jar() + subprocess.run(["java", "-jar", get_geoweaver_jar_path(), "run", "process", f"--host={host_id}", + f"--password={password}", f"--environment={environment}", process_id], + cwd=f"{get_root_dir()}/") + def run_worklfow(*, workflow_id, workflow_folder_path, workflow_zip_file_path, environments, host, password): """ Missing required parameter: '' diff --git a/pyproject.toml b/pyproject.toml index 2767b4a..ef65fa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta" [project] diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..44b8b0e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[metadata] +name = example +version = 0.6.0 + +[options] +packages = find: From 36194348e8c73d29f9bf9a10e445465dd49f516b Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 16:03:34 -0400 Subject: [PATCH 18/27] test if publish workflow works --- .github/workflows/publish-to-test-pypi.yml | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/publish-to-test-pypi.yml diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml new file mode 100644 index 0000000..3a9d341 --- /dev/null +++ b/.github/workflows/publish-to-test-pypi.yml @@ -0,0 +1,37 @@ +name: Publish PyGeoweaver Python 🐍 distributions 📦 to PyPI and TestPyPI + +on: push + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file From 6bca5ce1d7b9d6e39bcb303f6c697457dd9d8c59 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 16:06:32 -0400 Subject: [PATCH 19/27] no test pypi --- .github/workflows/publish-to-test-pypi.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 3a9d341..47294f2 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -25,11 +25,6 @@ jobs: --sdist --wheel --outdir dist/ - - name: Publish distribution 📦 to Test PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository-url: https://test.pypi.org/legacy/ - name: Publish distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 From 71ee639b78a3addf9b23ab41ab99e6aaca5d0855 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 16:13:26 -0400 Subject: [PATCH 20/27] trusted publish --- .github/workflows/publish-to-test-pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 47294f2..968fe37 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -26,7 +26,7 @@ jobs: --wheel --outdir dist/ - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags') + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file From a0ca64dd31a9156e896d70978f81b4bc4961599c Mon Sep 17 00:00:00 2001 From: Gokul Prathin Date: Sun, 16 Apr 2023 16:26:11 -0400 Subject: [PATCH 21/27] resolve requests dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ef65fa1..a836f97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,5 +31,6 @@ homepage = "https://github.com/ESIPFed/pygeoweaver" [tool.poetry.dependencies] python = ">=3.7" setuptools = ">=61.0" +requests = "2.28.2" [tool.poetry.scripts] From e33dba5b6d5737589c4fb5fa6c0c6622cc1e7aaa Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 16:48:03 -0400 Subject: [PATCH 22/27] move to test --- .github/workflows/publish-to-test-pypi.yml | 2 +- pygeoweaver/__init__.py | 2 ++ pygeoweaver/__main__.py | 15 +++++---- pygeoweaver/sc_interface.py | 10 ++++++ test/__init__.py | 0 test/test_all.py | 39 ++++++++++++++++++++++ 6 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 pygeoweaver/sc_interface.py create mode 100644 test/__init__.py diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 968fe37..3e56df7 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -26,7 +26,7 @@ jobs: --wheel --outdir dist/ - name: Publish distribution 📦 to PyPI - # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/pygeoweaver/__init__.py b/pygeoweaver/__init__.py index e69de29..d205e67 100644 --- a/pygeoweaver/__init__.py +++ b/pygeoweaver/__init__.py @@ -0,0 +1,2 @@ + +from pygeoweaver.sc_interface import * diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py index 6a5a9aa..1ca2359 100644 --- a/pygeoweaver/__main__.py +++ b/pygeoweaver/__main__.py @@ -2,12 +2,12 @@ The main function of pygeoweaver To run in CLI mode. """ -from pygeoweaver.sc_detail import detail_host, detail_process, detail_workflow -from pygeoweaver.sc_export import export_workflow -from pygeoweaver.sc_history import show_history -from pygeoweaver.sc_import import import_workflow -from pygeoweaver.sc_list import list_hosts, list_processes, list_workflows -from pygeoweaver.server import start, stop +from pygeoweaver import detail_host, detail_process, detail_workflow +from pygeoweaver import export_workflow +from pygeoweaver import show_history +from pygeoweaver import import_workflow +from pygeoweaver import list_hosts, list_processes, list_workflows +from pygeoweaver import start, stop def main(): # start geoweaver @@ -29,7 +29,8 @@ def main(): #import_workflow("/Users/joe/Downloads/gr3ykr8dynu12vrwq11oy.zip") # export workflow export_workflow("gr3ykr8dynu12vrwq11oy", "4", "/Users/joe/Downloads/test_pygeoweaver_export.zip") - + # run workflow + if __name__ == "__main__": main() \ No newline at end of file diff --git a/pygeoweaver/sc_interface.py b/pygeoweaver/sc_interface.py new file mode 100644 index 0000000..e0f933d --- /dev/null +++ b/pygeoweaver/sc_interface.py @@ -0,0 +1,10 @@ +""" +All functions of subcommand interfaces +""" +from pygeoweaver.sc_detail import * +from pygeoweaver.sc_list import * +from pygeoweaver.sc_export import * +from pygeoweaver.sc_history import * +from pygeoweaver.sc_import import * +from pygeoweaver.sc_list import * +from pygeoweaver.sc_run import * diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/test_all.py b/test/test_all.py index e69de29..fdd2f98 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -0,0 +1,39 @@ +""" +The main function of pygeoweaver +To run in CLI mode. +""" +from pygeoweaver import detail_host, detail_process, detail_workflow +from pygeoweaver import export_workflow +from pygeoweaver import show_history +from pygeoweaver import import_workflow +from pygeoweaver import list_hosts, list_processes, list_workflows +from pygeoweaver import start, stop + +import unittest + +class Testing(unittest.TestCase): + + def test_main(): + # start geoweaver + #start() + # stop geoweaver + # stop() + # list resources + #list_hosts() + #list_processes() + list_workflows() + # show history + #show_history("ll3u3W78eOEfklxhBJ") + # detail host + # detail_host("100001") + # detail process + # detail_process("7pxu8c") + #detail_workflow("5jnhcrq33znbu2mue9v2") + # import workflow + #import_workflow("/Users/joe/Downloads/gr3ykr8dynu12vrwq11oy.zip") + # export workflow + export_workflow("gr3ykr8dynu12vrwq11oy", "4", "/Users/joe/Downloads/test_pygeoweaver_export.zip") + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file From 44fb7d738b1dee96a0d5a58f95cf190257b0406b Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 16:49:25 -0400 Subject: [PATCH 23/27] bump version --- pyproject.toml | 2 +- setup.cfg | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a836f97..e36b1a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pygeoweaver" -version = "0.6.0" +version = "0.6.1" authors = [ { name="Geoweaver team", email="geoweaver.app@gmail.com" }, ] diff --git a/setup.cfg b/setup.cfg index 44b8b0e..0a641d2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] -name = example -version = 0.6.0 +name = pygeoweaver [options] packages = find: From 826357e9b016ab70e805f8a3ae136db5b11aae78 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 16:54:05 -0400 Subject: [PATCH 24/27] trust publish --- .github/workflows/publish-to-test-pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 3e56df7..968fe37 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -26,7 +26,7 @@ jobs: --wheel --outdir dist/ - name: Publish distribution 📦 to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file From 416990381453398a1d25d76d98869a54130c0fca Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 17:19:54 -0400 Subject: [PATCH 25/27] test tags --- .../{publish-to-test-pypi.yml => publish-to-pypi.yml} | 2 +- pygeoweaver/__main__.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename .github/workflows/{publish-to-test-pypi.yml => publish-to-pypi.yml} (90%) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-pypi.yml similarity index 90% rename from .github/workflows/publish-to-test-pypi.yml rename to .github/workflows/publish-to-pypi.yml index 968fe37..47294f2 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -26,7 +26,7 @@ jobs: --wheel --outdir dist/ - name: Publish distribution 📦 to PyPI - # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/pygeoweaver/__main__.py b/pygeoweaver/__main__.py index 1ca2359..7ef4408 100644 --- a/pygeoweaver/__main__.py +++ b/pygeoweaver/__main__.py @@ -11,13 +11,13 @@ def main(): # start geoweaver - #start() + start() # stop geoweaver # stop() # list resources #list_hosts() #list_processes() - list_workflows() + # list_workflows() # show history #show_history("ll3u3W78eOEfklxhBJ") # detail host @@ -28,9 +28,9 @@ def main(): # import workflow #import_workflow("/Users/joe/Downloads/gr3ykr8dynu12vrwq11oy.zip") # export workflow - export_workflow("gr3ykr8dynu12vrwq11oy", "4", "/Users/joe/Downloads/test_pygeoweaver_export.zip") + # export_workflow("gr3ykr8dynu12vrwq11oy", "4", "/Users/joe/Downloads/test_pygeoweaver_export.zip") # run workflow - + if __name__ == "__main__": main() \ No newline at end of file From 05248ddb441cc44e729948daf8c28bc53a42f299 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 17:20:32 -0400 Subject: [PATCH 26/27] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e36b1a5..9e72763 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ classifiers = [ [tool.poetry] name = "pygeoweaver" -version = "0.6.0" +version = "0.6.2" description = "This is a wrapper package of the Geoweaver app." authors = ["Geoweaver team "] readme = "README.md" From 256685012e18adb8a43e806cdbd11678cd516815 Mon Sep 17 00:00:00 2001 From: Ziheng Sun Date: Sun, 16 Apr 2023 17:22:14 -0400 Subject: [PATCH 27/27] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9e72763..2e8b96b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pygeoweaver" -version = "0.6.1" +version = "0.6.2" authors = [ { name="Geoweaver team", email="geoweaver.app@gmail.com" }, ]