-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from DubiousCactus/builder
Builder
- Loading branch information
Showing
21 changed files
with
973 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Launch Train [exp_a]", | ||
"type": "python", | ||
"request": "launch", | ||
"python": "/Users/cactus/miniforge3/envs/bellsnw/bin/python", | ||
"autoReload": { "enable": true }, | ||
"program": "${workspaceFolder}/train.py", | ||
"args": ["+experiment=exp_a", "dataset.tiny=1"] | ||
}, | ||
{ | ||
"name": "Launch Build [exp_a]", | ||
"type": "python", | ||
"request": "launch", | ||
"python": "/Users/cactus/miniforge3/envs/bellsnw/bin/python", | ||
"autoReload": { "enable": true }, | ||
"program": "${workspaceFolder}/build.py", | ||
"args": ["+experiment=exp_a", "dataset.tiny=1"] | ||
}, | ||
{ | ||
"name": "Attach Build [exp_a]", | ||
"type": "python", | ||
"request": "attach", | ||
"connect": { | ||
"host": "localhost", | ||
"port": 5555 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from dataclasses import dataclass | ||
from functools import partial | ||
from typing import Any, Callable, Optional | ||
|
||
from hydra_zen.typing import Partial | ||
|
||
|
||
class MatchboxModule: | ||
PREV = "MatchboxModule.PREV" # TODO: This is used as an enum value. Should figure it out | ||
|
||
def __init__(self, name: str, fn: Callable | Partial, *args, **kwargs): | ||
# TODO: Figure out this entire class. It's a hack, I'm still figuring things | ||
# out as I go. | ||
self._str_rep = name | ||
self.underlying_fn = fn.func if isinstance(fn, partial) else fn | ||
self.partial = partial(fn, *args, **kwargs) | ||
|
||
def __call__(self, prev_result: Any) -> Any: | ||
# TODO: Replace .PREV in any of the function's args/kwargs with prev_result | ||
for i, arg in enumerate(self.partial.args): | ||
if arg == self.PREV: | ||
assert prev_result is not None | ||
self.partial.args[i] = prev_result | ||
for key, value in self.partial.keywords.items(): | ||
if value == self.PREV: | ||
assert prev_result is not None | ||
self.partial.keywords[key] = prev_result | ||
return self.partial() | ||
|
||
def __str__(self) -> str: | ||
return self._str_rep | ||
|
||
|
||
@dataclass | ||
class MatchboxModuleState: | ||
first_run: bool | ||
result: Any | ||
is_frozen: bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.