diff --git a/dysweep/__init__.py b/dysweep/__init__.py index be47bad..54a7e7e 100644 --- a/dysweep/__init__.py +++ b/dysweep/__init__.py @@ -1,4 +1,4 @@ from .parallel import dysweep_run_resume, ResumableSweepConfig from .wandbX import hierarchical_config -__version__ = "0.0.2" +__version__ = "0.0.3" diff --git a/dysweep/parallel.py b/dysweep/parallel.py index dc44661..fb1a138 100644 --- a/dysweep/parallel.py +++ b/dysweep/parallel.py @@ -1,7 +1,7 @@ from dataclasses import dataclass import typing as th from pathlib import Path -from .wandbX import sweep, agent +from .wandbX import sweep, agent, hierarchical_config import functools from random_word import RandomWords import json @@ -129,7 +129,7 @@ def modified_function(): name=run_name, ) experiment_id = logger.experiment.id - sweep_config = logger.experiment.config + sweep_config = hierarchical_config(logger.experiment.config) else: import wandb wandb.init( @@ -138,12 +138,12 @@ def modified_function(): name=run_name, ) experiment_id = wandb.run.id - sweep_config = wandb.config + sweep_config = hierarchical_config(wandb.config) new_dir_name = f"{len(all_subdirs)+1}{SPLIT}{experiment_id}" os.makedirs(checkpoint_dir / new_dir_name) - + # dump a json in checkpoint_dir/run_id containing the sweep config with open(checkpoint_dir / new_dir_name / "sweep_config.json", "w") as f: json.dump(sweep_config, f) @@ -173,5 +173,10 @@ def modified_function(): agent(conf.sweep_id, function=modified_function, entity=conf.entity, project=conf.project, count=conf.count) else: - sweep(conf.base_config, conf.sweep_configuration, - entity=conf.entity, project=conf.project) + try: + sweep(conf.base_config, conf.sweep_configuration, + entity=conf.entity, project=conf.project) + except Exception as e: + print("Exception at creation of sweep:") + print(traceback.format_exc()) + raise e \ No newline at end of file diff --git a/dysweep/wandbX.py b/dysweep/wandbX.py index 3d8782c..8f06ef8 100644 --- a/dysweep/wandbX.py +++ b/dysweep/wandbX.py @@ -97,10 +97,8 @@ def agent(sweep_id, function=None, entity=None, project=None, count=None): compression = sweep_run.config['compression'] try: - wandb.sdk.wandb_run.Run.config = property( - _run_decorator._attach( - lambda self: hierarchical_config(self._config) - ) + wandb.sdk.wandb_run.Run.hierarchical_config = property( + lambda self: hierarchical_config(self.config) ) except Exception as e: warnings.warn( diff --git a/testing/main_sweep_user.py b/testing/main_sweep_user.py index 6150d7a..566c735 100644 --- a/testing/main_sweep_user.py +++ b/testing/main_sweep_user.py @@ -9,7 +9,7 @@ def f(): try: wandb.init(project="hierarchical_sweep") - conf = wandb.config + conf = wandb.run.hierarchical_config pprint(conf) except Exception as e: print(traceback.format_exc())