Skip to content

Commit

Permalink
debug functionalities of the sweep upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
HamidrezaKmK committed May 22, 2023
1 parent 12b2b9b commit c77d7d9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dysweep/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .parallel import dysweep_run_resume, ResumableSweepConfig
from .wandbX import hierarchical_config

__version__ = "0.0.2"
__version__ = "0.0.3"
17 changes: 11 additions & 6 deletions dysweep/parallel.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -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
6 changes: 2 additions & 4 deletions dysweep/wandbX.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion testing/main_sweep_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit c77d7d9

Please sign in to comment.