From 21715e36662469a6b1728e224cd932324f168bb7 Mon Sep 17 00:00:00 2001 From: Henry Senyondo Date: Tue, 16 Apr 2024 15:22:44 -0400 Subject: [PATCH 1/2] Mbites renaming removed --- combine_birds_site_year.py | 2 +- mbtile.py | 3 --- tools.py | 18 ++++++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/combine_birds_site_year.py b/combine_birds_site_year.py index 8826816..d3de956 100644 --- a/combine_birds_site_year.py +++ b/combine_birds_site_year.py @@ -19,7 +19,7 @@ def combine_files(bird_detection_files, year, site, score_thresh, savedir): eventdf["Site"] = tools.get_site(x) eventdf["Date"] = tools.get_date(x) eventdf["Year"] = tools.get_year(x) - eventdf["event"] = tools.get_event(x) + eventdf["event"], eventdf["file_postscript"] = tools.get_event(x) eventdf = eventdf[eventdf.score > score_thresh] df.append(eventdf) except IndexError as e: diff --git a/mbtile.py b/mbtile.py index 4dcd3b8..b203a2e 100644 --- a/mbtile.py +++ b/mbtile.py @@ -12,9 +12,6 @@ def create_mbtile(path, year, site, force_upload=False): basename = os.path.splitext(os.path.basename(path))[0] flight = basename.replace("_projected", "") - if tools.get_event(basename) == "primary": - flight = "_".join(basename.split('_')[0:4]) - working_dir = tools.get_working_dir() mbtiles_dir = os.path.join(working_dir, "mapbox", year, site) if not os.path.exists(mbtiles_dir): diff --git a/tools.py b/tools.py index 4f83be7..2e7716b 100644 --- a/tools.py +++ b/tools.py @@ -23,13 +23,19 @@ def get_event(path): This function returns "primary" for no event and events with the following values: "A", "a", "primary", "PRIMARY", or mixed case versions of "primary" """ - path = os.path.basename(path) - regex = re.compile('\\w+_\\d+_\\d+_\\d+_(\\w+)_projected') - match = regex.match(path) - if match and match.group(1).upper() != "A" and match.group(1).upper() != "PRIMARY": - return match.group(1) + filename = os.path.basename(path) + regex = re.compile(r'\w+_\d+_\d+_\d+_(\w+)_projected') + match = regex.match(filename) + + if match: + event = match.group(1).upper() + if event not in {"A", "PRIMARY"}: + return (event, "_" + event) + else: + return ("primary", "_" + event) else: - return "primary" + return ("primary", "") + def get_site(path): From 2747edc036eada72e4460c34cd07745505d29115 Mon Sep 17 00:00:00 2001 From: Henry Senyondo Date: Mon, 22 Apr 2024 12:56:10 -0400 Subject: [PATCH 2/2] Detect event return a tuple, use event[0] --- Snakefile | 2 +- everglades_workflow.sh | 6 +++--- tools.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Snakefile b/Snakefile index ef50598..d1e4565 100644 --- a/Snakefile +++ b/Snakefile @@ -26,7 +26,7 @@ def flights_in_year_site(wildcards): flight_path = os.path.join(basepath, year, site, f"{flight}_projected.shp") # Assuming there is a tools.get_event function event = tools.get_event(flight_path) - if site == wildcards.site and year == wildcards.year and event == "primary": + if site == wildcards.site and year == wildcards.year and event[0] == "primary": flights_in_year_site.append(flight_path) return flights_in_year_site diff --git a/everglades_workflow.sh b/everglades_workflow.sh index ddc715c..c47d4da 100644 --- a/everglades_workflow.sh +++ b/everglades_workflow.sh @@ -2,8 +2,8 @@ #SBATCH --job-name=everglades_workflow #SBATCH --mail-user=henrysenyondo@ufl.edu #SBATCH --mail-type=FAIL -#SBATCH --gpus=a100:1 -#SBATCH --cpus-per-task=30 +#SBATCH --gpus=a100:4 +#SBATCH --cpus-per-task=60 #SBATCH --mem=1200gb #SBATCH --time=80:00:00 #SBATCH --partition=gpu @@ -22,5 +22,5 @@ cd /blue/ewhite/everglades/EvergladesTools/Zooniverse snakemake --unlock echo "INFO [$(date "+%Y-%m-%d %H:%M:%S")] Starting Snakemake pipeline" -snakemake --printshellcmds --keep-going --cores 30 --resources gpu=1 --rerun-incomplete --latency-wait 10 --use-conda +snakemake --printshellcmds --keep-going --cores 60 --resources gpu=4 --rerun-incomplete --latency-wait 10 --use-conda echo "INFO [$(date "+%Y-%m-%d %H:%M:%S")] End" diff --git a/tools.py b/tools.py index 2e7716b..b0309df 100644 --- a/tools.py +++ b/tools.py @@ -37,7 +37,6 @@ def get_event(path): return ("primary", "") - def get_site(path): path = os.path.basename(path) regex = re.compile("(\\w+)_\\d+_\\d+_\\d+.*_projected")