Skip to content

Commit

Permalink
add notes
Browse files Browse the repository at this point in the history
  • Loading branch information
xingzhongyu committed Dec 20, 2024
1 parent 5b3d2de commit a18f3ae
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions examples/atlas/setup_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@


def load_commands(config_path):
"""Load YAML configuration file containing command templates for different
algorithms."""
with open(config_path, encoding='utf-8') as f:
return yaml.safe_load(f)


def load_run_configs(run_config_path):
"""Load CSV file containing run configurations for different experiments."""
return pd.read_csv(run_config_path)


Expand All @@ -25,11 +28,13 @@ def main():

args = parser.parse_args()

# Load configuration files
run_configs_df = load_run_configs(args.config)

commands_config = load_commands("config/commands.yaml")

# Process each run configuration
for _, run in run_configs_df.iterrows():
# Extract parameters for current run
algorithm_name = run['algorithm_name']
dataset_id = run['dataset_id']
species = run['species']
Expand All @@ -38,31 +43,36 @@ def main():
count = run['count']
device = run['device']

# Define paths
# Setup directory structure for the algorithm configuration
template_path = os.path.join("config/atlas_template_yamls",
f"{algorithm_name}/pipeline_params_tuning_config.yaml")
config_dir = f"{DANCEDIR}/examples/tuning/{algorithm_name}/{dataset_id}"

# Create configuration directory if it doesn't exist
try:
os.makedirs(config_dir, exist_ok=False)
except FileExistsError:
logger.warning(f"Error: Directory {config_dir} already exists. Please remove it before running again.")
continue

config_filename = f"pipeline_params_tuning_config.yaml"
config_path = os.path.join(config_dir, config_filename)

# Copy configuration file
shutil.copy(template_path, config_path)
print(f"Template copied to {config_path}")

# Validate algorithm exists in commands configuration
if algorithm_name not in commands_config.get("algorithms", {}):
print(f"Error: Command not found for algorithm '{algorithm_name}'. Please check commands.yaml file.")
continue

# Format command template with run parameters
command_template = commands_config["algorithms"][algorithm_name]["command"]
run_command = command_template.format(dataset_id=dataset_id, species=species, tissue=tissue, filetype=filetype,
count=count, device=device)

# Append the run command to run.sh
# Append generated command to run script
run_sh_path = f"{DANCEDIR}/examples/tuning/{algorithm_name}/run.sh"
with open(run_sh_path, "a", encoding='utf-8') as run_script:
run_script.write(f"{run_command}\n")
Expand Down

0 comments on commit a18f3ae

Please sign in to comment.