FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 4e856356 authored by J.W. Smith's avatar J.W. Smith
Browse files

Env suit zip filename is now configurable. New Ethiopia season may need changes, not yet clear.

parent ccd2b99b
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,8 @@ my $debugTimeString = getTimestampNow();
my $debugOutput = 0;
my $debugNoFTPDownload = 0;
my $debugNoUpload = 0;
my $debugNoUpload = 1;
my $debugNoPlot = 1;
# read in project configuration from input argument
my $configFilePath = shift;
......@@ -46,6 +47,7 @@ my $jobIDString = "ENVIRONMENT";
my $todayFolderPath = $workspacePath."/".$jobIDString."_".$todayString;
my $ENVDirectoryPrefix = get_ENV_directory_prefix();
my @maintainersCam = ("jws52\@cam.ac.uk", "tm689\@cam.ac.uk", "rs481\@cam.ac.uk");
my @maintainersMO = ("william.thurston\@metoffice.gov.uk");
......@@ -230,7 +232,7 @@ beginRun();
#Enter destination for the files:
chdir($todayFolderPath) or handleError("ERROR: Unable to change working directory to output folder path :".$todayFolderPath);
my $todayOutputDir = "env_suit_wheatrust_".$todayString;
my $todayOutputDir = $ENVDirectoryPrefix.$todayString;
my $todayOutputFileName = $todayOutputDir.".tar.gz";
unless($debugNoFTPDownload) {
......@@ -241,19 +243,19 @@ unless($debugNoFTPDownload) {
if ($downloadFromWillow) {
# get from willow sftp
# If file is not there, script will not die, instead it prints warning to logfile
# If file is not there, script will not die, instead it prints warning to logfile
my $SCPCommand = "scp -i ".$coordinatorPath."/ssh_key_willow willow.csx.cam.ac.uk:/storage/sftp/metofficeupload/upload/".$projectName."/fromMO/daily_name/".$todayOutputFileName." ".$todayFolderPath."/";
# system returns 1 on failure, so perl picks this up with 'and'
system($SCPCommand) and handleDataNotAvailableByTime($ftpServerName);
} else {
# get from met office ftp server
#credentials stored separately so they aren't in plain text and checked in to the repo:
my $serverCredentialsFileName = $coordinatorPath."/MO_FTP_Cred.json";
my $ftpCredentialsString = read_file($serverCredentialsFileName) or handleError("ERROR: Unable to read FTP credentials from credentials file: ".$serverCredentialsFileName);
my $ftpCredentials = decode_json($ftpCredentialsString) or handleError("ERROR: Unable to parse credentials from JSON in credentials file: ".$serverCredentialsFileName);#Obviously don't ever print the _contents_ of the credentials file to the screen...
#credentials stored separately so they aren't in plain text and checked in to the repo:
my $serverCredentialsFileName = $coordinatorPath."/MO_FTP_Cred.json";
my $ftpCredentialsString = read_file($serverCredentialsFileName) or handleError("ERROR: Unable to read FTP credentials from credentials file: ".$serverCredentialsFileName);
my $ftpCredentials = decode_json($ftpCredentialsString) or handleError("ERROR: Unable to parse credentials from JSON in credentials file: ".$serverCredentialsFileName);#Obviously don't ever print the _contents_ of the credentials file to the screen...
$ftpServerName = $ftpCredentials->{"server"};
......@@ -295,8 +297,17 @@ unless(-d $todayOutputDir) {
#Check if the zip actually had output inside it - maininput.txt and at least one file of each depositionEthiopia_Stem_*.txt, depositionEthiopia_Stripe_*.txt
my @necessaryOutputs = (
$todayOutputDir."/StripeRustOutput/part_1/".$todayString."0000/RIE_value.csv",
$todayOutputDir."/WheatStemRustOutput/".$todayString."0000/stem_rust_which_stage.csv"
# environmental suitability version 1.0 (Ethiopia season 2019)
#$todayOutputDir."/StripeRustOutput/part_1/".$todayString."0000/RIE_value.csv",
#$todayOutputDir."/WheatStemRustOutput/".$todayString."0000/stem_rust_which_stage.csv"
#
# environmental suitability version 1.2.2 (South Asia season 2020)
$todayOutputDir."/StemRust_Bangladesh/".$todayString."0000/RIE_value.csv",
$todayOutputDir."/StripeRust_Bangladesh/".$todayString."0000/RIE_value.csv",
$todayOutputDir."/LeafRust_Bangladesh/".$todayString."0000/RIE_value.csv",
$todayOutputDir."/StemRust_Nepal/".$todayString."0000/RIE_value.csv",
$todayOutputDir."/StripeRust_Nepal/".$todayString."0000/RIE_value.csv",
$todayOutputDir."/LeafRust_Nepal/".$todayString."0000/RIE_value.csv",
);
foreach my $necessaryOutput (@necessaryOutputs) {
......@@ -305,9 +316,28 @@ foreach my $necessaryOutput (@necessaryOutputs) {
}
}
my $plotPath = $projectPath."/Plotting/";
if($debugNoPlot) {
#handleError("No plotting taking place", \@maintainersCam, $severityStringWARNING);
print("DEBUG: No plotting taking place");
#Successful run, no plotting expected at beginning of Feb 2020.
# placeholder file state this
my $noplotFilePath = $todayFolderPath."/".$jobIDString."_NO_PLOTTING.txt";
open(my $noplotFH, ">", $noplotFilePath) or handleError("ERROR: Unable to open confirmation file for writing: ".$doneFilePath);
print $noplotFH "Completed: ".getTimestampNow()."\n";
close($noplotFH) or handleError("ERROR: Unable to write ".$noplotFilePath);
#Flag overall success of operation:
open(my $successFH, ">", $doneFilePath) or handleError("ERROR: Unable to open confirmation file for writing: ".$doneFilePath);
print $successFH "Completed: ".getTimestampNow()."\n";
close($successFH) or handleError("ERROR: Unable to write ".$doneFilePath);
#Remove the in progress file and exit:
terminateRun();
}
#Move data to plotting inputs area:
system("cp -r ".$todayOutputDir."/StripeRustOutput ".$plotPath."/output/");
system("cp -r ".$todayOutputDir."/WheatStemRustOutput ".$plotPath."/output/");
......
......@@ -20,4 +20,7 @@ sub get_NAME_file_prefixes { return ("depositionEthiopia_Stem_","depositionEthio
sub get_expected_available_hour { return 8 };
sub get_expected_available_minute { return 0 };
# ENV processing
sub get_ENV_directory_prefix { return "env_suit_wheatrust_" };
1;
\ No newline at end of file
......@@ -26,4 +26,6 @@ sub get_NAME_file_prefixes { return ("deposition_srcs_allregions_") };
sub get_expected_available_hour { return 8 };
sub get_expected_available_minute { return 0 };
# ENV processing
sub get_ENV_directory_prefix { return "WR_EnvSuit_SouthAsia_" };
1;
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