-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
386 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,7 @@ Thumbs.db | |
|
||
|
||
slurm_scripts/slurm_logs* | ||
slurm_scripts/experiments* | ||
# other | ||
temp | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
OCR: | ||
ocr: | ||
specific_task: "image-to-text" | ||
model: "microsoft/trocr-base-handwritten" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ level: 1 | |
lang_pair: | ||
source: "fr" | ||
target: "en" | ||
|
||
drop_length: 1000 |
13 changes: 13 additions & 0 deletions
13
config/experiment/baskerville_pipeline_inference_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
data_config: l1_fr_to_en | ||
|
||
pipeline_config: roberta-mt5-zero-shot | ||
|
||
seed: | ||
- 42 | ||
|
||
bask: | ||
jobname: "shortened_input_test" | ||
walltime: '0-12:0:0' | ||
gpu_number: 1 | ||
node_number: 1 | ||
hf_cache_dir: "/bask/projects/v/vjgo8416-spice/hf_cache" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
data_config: l1_fr_to_en | ||
|
||
pipeline_config: roberta-mt5-zero-shot | ||
|
||
seed: | ||
- 42 | ||
- 43 | ||
- 44 | ||
|
||
bask: | ||
jobname: "full_experiment_with_zero_shot" | ||
walltime: '0-24:0:0' | ||
gpu_number: 1 | ||
node_number: 1 | ||
hf_cache_dir: "/bask/projects/v/vjgo8416-spice/hf_cache" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
from jinja2 import Environment, FileSystemLoader | ||
from jsonargparse import CLI | ||
|
||
from arc_spice.utils import open_yaml_path | ||
|
||
PROJECT_DIR = Path(__file__, "..", "..").resolve() | ||
|
||
|
||
def main(experiment_config_path: str): | ||
""" | ||
_summary_ | ||
Args: | ||
experiment_config_path: _description_ | ||
""" | ||
experiment_name = experiment_config_path.split("/")[-1].split(".")[0] | ||
experiment_config = open_yaml_path(experiment_config_path) | ||
pipeline_conf_dir = ( | ||
f"{PROJECT_DIR}/config/RTC_configs/{experiment_config['pipeline_config']}.yaml" | ||
) | ||
data_conf_dir = ( | ||
f"{PROJECT_DIR}/config/data_configs/{experiment_config['data_config']}.yaml" | ||
) | ||
pipeline_config = open_yaml_path(pipeline_conf_dir) | ||
# Get jinja template | ||
environment = Environment( | ||
loader=FileSystemLoader(PROJECT_DIR / "src" / "arc_spice" / "config") | ||
) | ||
template = environment.get_template("jobscript_template.sh") | ||
# We don't want to overwrite results | ||
|
||
for index, seed in enumerate(experiment_config["seed"]): | ||
os.makedirs( | ||
f"slurm_scripts/experiments/{experiment_name}/run_{index}", exist_ok=False | ||
) | ||
for model in pipeline_config: | ||
model_script_dict: dict = experiment_config["bask"] | ||
model_script_dict.update( | ||
{ | ||
"script_name": ( | ||
"scripts/single_component_inference.py " | ||
f"{pipeline_conf_dir} {data_conf_dir} {seed}" | ||
f" {experiment_name} {model}" | ||
), | ||
"job_name": f"{experiment_name}_{model}", | ||
"seed": seed, | ||
} | ||
) | ||
model_train_script = template.render(model_script_dict) | ||
|
||
with open( | ||
f"slurm_scripts/experiments/{experiment_name}/run_{index}/{model}.sh", | ||
"w", | ||
) as f: | ||
f.write(model_train_script) | ||
|
||
pipeline_script_dict: dict = experiment_config["bask"] | ||
pipeline_script_dict.update( | ||
{ | ||
"script_name": ( | ||
"scripts/pipeline_inference.py " | ||
f"{pipeline_conf_dir} {data_conf_dir} {seed}" | ||
f" {experiment_name}" | ||
), | ||
"job_name": f"{experiment_name}_full_pipeline", | ||
"seed": seed, | ||
} | ||
) | ||
pipeline_train_script = template.render(pipeline_script_dict) | ||
|
||
with open( | ||
f"slurm_scripts/experiments/{experiment_name}/run_{index}/full_pipeline.sh", | ||
"w", | ||
) as f: | ||
f.write(pipeline_train_script) | ||
|
||
|
||
if __name__ == "__main__": | ||
CLI(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
#SBATCH --account vjgo8416-spice | ||
#SBATCH --qos turing | ||
#SBATCH --job-name {{ job_name }} | ||
#SBATCH --time {{ walltime }} | ||
#SBATCH --nodes {{ node_number }} | ||
#SBATCH --gpus {{ gpu_number }} | ||
#SBATCH --output /bask/projects/v/vjgo8416-spice/ARC-SPICE/slurm_scripts/slurm_logs/{{ job_name }}-%j.out | ||
#SBATCH --cpus-per-gpu 18 | ||
|
||
|
||
# Load required modules here | ||
module purge | ||
module load baskerville | ||
module load bask-apps/live/live | ||
module load Python/3.10.8-GCCcore-12.2.0 | ||
|
||
|
||
# change working directory | ||
cd /bask/projects/v/vjgo8416-spice/ARC-SPICE/ | ||
|
||
source /bask/projects/v/vjgo8416-spice/ARC-SPICE/env/bin/activate | ||
|
||
# change huggingface cache to be in project dir rather than user home | ||
export HF_HOME="{{ hf_cache_dir }}" | ||
|
||
# TODO: script uses relative path to project home so must be run from home, fix | ||
python {{ script_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.