Skip to content

Commit

Permalink
Forgot to add this one line
Browse files Browse the repository at this point in the history
  • Loading branch information
skrawcz committed Mar 7, 2024
1 parent 3a4b959 commit 52cb8d3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.with_modules(build, eq, tg)
# .with_config(config)
.with_adapters(tracker_hook, CachingGraphAdapter(".cache"))
.enable_dynamic_execution(allow_experimental_mode=True)
.with_execution_manager(execution_manager)
.build()
)
Expand Down
64 changes: 64 additions & 0 deletions example/run_batch1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from pathlib import Path
import build
import eq
import tg

from hamilton import driver
from hamilton.io.materialization import to
from hamilton.experimental.h_cache import CachingGraphAdapter
from hamilton.plugins import h_experiments, matplotlib_extensions, pandas_extensions # noqa: F401

from molexp.cmdline import CMDLineExecutionManager
from hamilton.execution import executors

tracker_hook = h_experiments.ExperimentTracker(
experiment_name="exp",
base_directory="./experiments",
)

execution_manager = CMDLineExecutionManager(
executors.SynchronousLocalTaskExecutor(),
executors.MultiThreadingExecutor(20), # max parallelism
)

dr = (
driver.Builder()
.with_modules(build, eq, tg)
# .with_config(config)
.with_adapters(tracker_hook, CachingGraphAdapter(".cache"))
.with_execution_manager(execution_manager)
.build()
)

inputs = dict(
{
# 'work_dir': ''
"repeat_unit": ["N", "M"],
"repeat": 1,
"n_chains": 20,
"density": 0.005,
}
)

materializers = [
to.pickle(
id="after_build",
dependencies=["submit"],
path="/proj/snic2021-5-546/users/x_jicli/exp/.cache/to_lammps.pickle",
)
]

for repeat_unit in ["NMNMP", "NMNMNMP"]:
for repeat in [1, 4, 8]:
inputs["repeat_unit"] = list(repeat_unit)
inputs["repeat"] = repeat

inputs["work_dir"] = f"{''.join(inputs['repeat_unit'])}x{inputs['repeat']}"
Path(inputs["work_dir"]).mkdir(exist_ok=True)
dr.visualize_materialization(
*materializers,
inputs=inputs,
output_file_path=f"{tracker_hook.run_directory}/dag",
render_kwargs=dict(view=False, format="png"),
)
dr.materialize(*materializers, inputs=inputs)

0 comments on commit 52cb8d3

Please sign in to comment.