Skip to content

Commit

Permalink
[docs] added top level docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
mathysgrapotte committed Nov 25, 2024
1 parent 7ffd173 commit 4e9feef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/stimulus/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""stimulus-py command line interface.
This module contains command line tools, those are mainly used by the nf-core pipeline deepmodeloptim, available at https://github.com/nf-core/deepmodeloptim
However, one can use them independently if they wish.
"""
4 changes: 4 additions & 0 deletions src/stimulus/cli/analysis_default.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env python3

"""
Analysis default module is used to analyze the general performance of any model on any task, it is launched by default by deepmodeloptim, hence the name.
"""

import argparse
import json
import os
Expand Down
23 changes: 12 additions & 11 deletions src/stimulus/cli/check_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env python3

"""
Check model module is used to check model "soudness" before launching full tuning.
It incorporates various checks
"""

import argparse
import json
import os
Expand Down Expand Up @@ -124,19 +130,19 @@ def main(
ray_results_dirpath: str = None,
_debug_mode: str = False,
) -> None:
# TODO update to yaml the experimnt config
# load json into dictionary

exp_config = {}
with open(experiment_config) as in_json:
exp_config = json.load(in_json)
exp_config = json.load(in_json)

# Initialize json schema it checks for correctness of the Json architecture and fields / values. already raises errors.
# json is soon deprecated and will be removed in favour of a yaml config file.

# in theory, checking json should happen in a seperate utility
schema = JsonSchema(exp_config)

# initialize the experiment class
initialized_experiment_class = get_experiment(schema.experiment)

# import the model correctly but do not initialize it yet, ray_tune does that itself
model_class = import_class_from_file(model_path)

# Update the tune config file. no need to run the whole amount asked for the tuning. Basically downsample the tuning.
Expand All @@ -159,14 +165,9 @@ def main(
if initial_weights_path is not None:
user_tune_config["model_params"]["initial_weights"] = os.path.abspath(initial_weights_path)

# TODO future schedulers specific info will go here as well. maybe find a cleaner way.

# TODO check if among the first 2 values of all splitters params there is a percentage that makes the resulting split smaller that the biggest batch value

# save to file the new dictionary because StimulusTuneWrapper only takes paths
yaml.dump(user_tune_config, new_conf)

# initialize the csv processing class, it open and reads the csv in automatic
csv_obj = CsvProcessing(initialized_experiment_class, data_path)
downsampled_csv = "downsampled.csv"

Expand All @@ -184,7 +185,7 @@ def main(
# compute the memory requirements for ray init. Usefull in case ray detects them wrongly. Memory is split in two for ray: for store_object memory and the other actual memory for tuning. The following function takes the total possible usable/allocated memory as a string parameter and return in bytes the values for store_memory (30% as default in ray) and memory (70%).
object_store_mem, mem = memory_split_for_ray_init(memory)

# set ray_result dir ubication. TODO this version of pytorch does not support relative paths, in future maybe good to remove abspath.
# set ray_result dir
ray_results_dirpath = None if ray_results_dirpath is None else os.path.abspath(ray_results_dirpath)

# Create the learner
Expand Down

0 comments on commit 4e9feef

Please sign in to comment.