FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit b8ee59e9 authored by L. Bower's avatar L. Bower
Browse files

more work swapping ssh and scp commands for when run in local mode

parent d4c81ff6
No related branches found
No related tags found
No related merge requests found
...@@ -40,11 +40,12 @@ def process_in_job_env2_0(jobPath,status,config,component): ...@@ -40,11 +40,12 @@ def process_in_job_env2_0(jobPath,status,config,component):
# TODO: perform ssh file transfer in python instead of subprocess # TODO: perform ssh file transfer in python instead of subprocess
server_name: str = config['ServerName'] server_name: str = config['ServerName']
machine_seperator: str = ":" if server_name == "":
if not server_name: cmd_scp: list = ["scp", f"{file_path}/{file_name}.tar.gz", jobPath]
machine_seperator = "" else:
cmd_scp: list = ["scp", "-i", config['ServerKey'], "-o", "StrictHostKeyChecking=no",
f"{config['ServerName']}:{file_path}/{file_name}.tar.gz", jobPath]
cmd_scp: list = ["scp","-i",config['ServerKey'],"-o","StrictHostKeyChecking=no",f"{config['ServerName']}{machine_seperator}{file_path}/{file_name}.tar.gz", jobPath]
description_short = 'env2 scp' description_short = 'env2 scp'
description_long = 'Copying file from remote server to job directory' description_long = 'Copying file from remote server to job directory'
# lawrence comment in/out # lawrence comment in/out
......
...@@ -42,7 +42,7 @@ def process_pre_job_server_download(input_args: dict): ...@@ -42,7 +42,7 @@ def process_pre_job_server_download(input_args: dict):
timenow = datetime.datetime.now(tz=datetime.timezone.utc).time() timenow = datetime.datetime.now(tz=datetime.timezone.utc).time()
server_name: str = config['ServerName'] server_name: str = config['ServerName']
full_file_path = f"{file_path} / {file_name}.tar.gz" full_file_path = f"{file_path}/{file_name}.tar.gz"
if server_name == "": if server_name == "":
cmd_check_file = [f"test -f {full_file_path} && tar -tzf {full_file_path} > /dev/null"] cmd_check_file = [f"test -f {full_file_path} && tar -tzf {full_file_path} > /dev/null"]
run_in_shell: bool = True run_in_shell: bool = True
...@@ -57,7 +57,7 @@ def process_pre_job_server_download(input_args: dict): ...@@ -57,7 +57,7 @@ def process_pre_job_server_download(input_args: dict):
status = subprocess_and_log(cmd_check_file, description_short, description_long, check = False, status = subprocess_and_log(cmd_check_file, description_short, description_long, check = False,
shell = run_in_shell) shell = run_in_shell)
if status.returncode == 1: if status.returncode > 0:
# a time check in UTC. If it's late, raise warning, if very late, raise error # a time check in UTC. If it's late, raise warning, if very late, raise error
...@@ -122,15 +122,26 @@ def upload(config,FilesToSend,component): ...@@ -122,15 +122,26 @@ def upload(config,FilesToSend,component):
logger.debug("Making path directory on remote server if it doesn't already exist") logger.debug("Making path directory on remote server if it doesn't already exist")
ssh_cmd = ["ssh","-i",config['ServerKey'],"-o","StrictHostKeyChecking=no",config['ServerName'], f"mkdir -p {OutputServerPath}"] server_key = config['ServerKey']
if server_key == "":
ssh_cmd = ["ssh", f"mkdir -p {OutputServerPath}"]
run_in_shell: bool = True
else:
ssh_cmd = ["ssh", "-i", server_key, "-o", "StrictHostKeyChecking=no", config['ServerName'],
f"mkdir -p {OutputServerPath}"]
run_in_shell: bool = False
description_short = 'upload ssh' description_short = 'upload ssh'
description_long = 'make remote directory' description_long = 'make remote directory'
subprocess_and_log(ssh_cmd, description_short, description_long) subprocess_and_log(ssh_cmd, description_short, description_long, shell=run_in_shell)
logger.debug('Sending file(s) to remote server') logger.debug('Sending file(s) to remote server')
scp_cmd = ["scp","-ri",config['ServerKey'],"-o","StrictHostKeyChecking=no",*FilesToSend, f"{config['ServerName']}:{OutputServerPath}"] if server_key == "":
scp_cmd = ["scp", *FilesToSend, {OutputServerPath}]
else:
scp_cmd = ["scp", "-ri", server_key, "-o", "StrictHostKeyChecking=no", *FilesToSend,
f"{config['ServerName']}:{OutputServerPath}"]
description_short = 'upload scp' description_short = 'upload scp'
description_long = 'scp files to remote directory' description_long = 'scp files to remote directory'
......
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
}, },
"Epidemiology" : { "Epidemiology" : {
"DiseaseNames" : ["StemRust"], "DiseaseNames" : ["StemRust"],
"CalculationSpanDays" : ["20220501",5], "CalculationSpanDays" : [0,1],
"TimeStep_hours": "3", "TimeStep_hours": "3",
"ProcessPreJob" : "process_pre_job_epi", "ProcessPreJob" : "process_pre_job_epi",
"ProcessInJob" : "process_in_job_epi", "ProcessInJob" : "process_in_job_epi",
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
"ProcessPreJob" : "query_past_successes", "ProcessPreJob" : "query_past_successes",
"ProcessInJob" : "process_in_job_advisory", "ProcessInJob" : "process_in_job_advisory",
"ProcessEWSPlotting" : "do_nothing", "ProcessEWSPlotting" : "do_nothing",
"seasonStartString" : "20220501", "seasonStartString" : "20210901",
"Environment" : { "Environment" : {
"SuccessFileTemplate" : "${WorkspacePath}ENVIRONMENT_2.0_${StartString}/STATUS_SUCCESS", "SuccessFileTemplate" : "${WorkspacePath}ENVIRONMENT_2.0_${StartString}/STATUS_SUCCESS",
"DataPathTemplate" : "${WorkspacePath}/ENVIRONMENT_2.0_${dateString}/plotting/${SubRegionNameLower}/input_csvs/", "DataPathTemplate" : "${WorkspacePath}/ENVIRONMENT_2.0_${dateString}/plotting/${SubRegionNameLower}/input_csvs/",
...@@ -270,7 +270,7 @@ ...@@ -270,7 +270,7 @@
} }
}, },
"Surveys" : { "Surveys" : {
"variety_names_tidy_fn" : "/media/scratch/lb584_scratch/projects/ews_local_prod/regions/EastAfrica/resources/advisory_builder/configs/config_EastAfrica_variety_names_tidy.json", "variety_names_tidy_fn" : "../test_data/test_deployment/regions/EastAfrica/resources/advisory_builder/configs/config_EastAfrica_variety_names_tidy.json",
"CountryColumnName" : "surveyor_infromation-country", "CountryColumnName" : "surveyor_infromation-country",
"EastAfrica" : { "EastAfrica" : {
"ShapeFilenameAdmin0" : "../test_data/test_deployment/regions/EastAfrica/resources/advisory_builder/assets/EthKen_admin0.shp", "ShapeFilenameAdmin0" : "../test_data/test_deployment/regions/EastAfrica/resources/advisory_builder/assets/EthKen_admin0.shp",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment