forked from mmistakes/minimal-mistakes
-
Notifications
You must be signed in to change notification settings - Fork 0
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 mmistakes#40 from pesser/hackday2
fix hanging process
- Loading branch information
Showing
5 changed files
with
116 additions
and
36 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
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
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
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,23 @@ | ||
import subprocess, os | ||
from edflow.main import _train | ||
from edflow.custom_logging import init_project | ||
|
||
|
||
def fullname(o): | ||
"""Get string to specify class in edflow config.""" | ||
module = o.__module__ | ||
return module + "." + o.__name__ | ||
|
||
|
||
def run_edflow_cmdline(command): | ||
"""Just make sure example runs without errors.""" | ||
env = os.environ.copy() | ||
if not "CUDA_VISIBLE_DEVICES" in env: | ||
env["CUDA_VISIBLE_DEVICES"] = "0" | ||
subprocess.run(command, shell=True, check=True, env=env) | ||
|
||
|
||
def run_edflow(name, config): | ||
"""Run edflow directly from config.""" | ||
P = init_project("logs", code_root=None, postfix=name) | ||
_train(config, P.root) |
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,44 @@ | ||
import pytest, subprocess | ||
from common import run_edflow, fullname | ||
from edflow.iterators.model_iterator import PyHookedModelIterator | ||
from edflow.iterators.batches import DatasetMixin | ||
|
||
|
||
class Model(object): | ||
def __init__(self, config): | ||
self.config = config | ||
|
||
|
||
class Iterator(PyHookedModelIterator): | ||
def initialize(self, *args, **kwargs): | ||
raise Exception("TestAbort") | ||
|
||
|
||
class Dataset(DatasetMixin): | ||
def __init__(self, config): | ||
self.config = config | ||
|
||
def __len__(self): | ||
return 1000 | ||
|
||
def get_example(self, i): | ||
return {"foo": 0} | ||
|
||
|
||
def run_test(): | ||
config = dict() | ||
config["model"] = fullname(Model) | ||
config["iterator"] = fullname(Iterator) | ||
config["dataset"] = fullname(Dataset) | ||
config["batch_size"] = 16 | ||
config["num_steps"] = 100 | ||
run_edflow("0024", config) | ||
|
||
|
||
def test(): | ||
subprocess.run( | ||
'python -c "from test_hanging_process import run_test; run_test()"', | ||
shell=True, | ||
check=False, | ||
timeout=60, | ||
) |