From 88fce0743babbf495e7fbbcf21092b8c97d54d46 Mon Sep 17 00:00:00 2001 From: Hironori Yamamoto Date: Tue, 8 Oct 2024 20:48:19 +0900 Subject: [PATCH] tmp --- gokart/task.py | 3 +- test/test_build.py | 1 - test/test_dependencies.py | 66 +++++++++++++++++++-------------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/gokart/task.py b/gokart/task.py index 60cfcd31..b3beda1f 100644 --- a/gokart/task.py +++ b/gokart/task.py @@ -112,7 +112,6 @@ def __init__(self, *args, **kwargs): super(TaskOnKart, self).__init__(*args, **kwargs) self._rerun_state = self.rerun self._lock_at_dump = True - self.run = resolve_run_dependencies_wrapper(self.run, self.param_kwargs) # type: ignore if self.complete_check_at_run: self.run = task_complete_check_wrapper(run_func=self.run, complete_check_func=self.complete) # type: ignore @@ -124,6 +123,8 @@ def __init__(self, *args, **kwargs): task_lock_params = make_task_lock_params_for_run(task_self=self) self.run = wrap_run_with_lock(run_func=self.run, task_lock_params=task_lock_params) # type: ignore + self.run = resolve_run_dependencies_wrapper(self.run, self.param_kwargs) # type: ignore + def input(self) -> FlattenableItems[TargetOnKart]: return super().input() diff --git a/test/test_build.py b/test/test_build.py index 0e93d3e0..3821be8a 100644 --- a/test/test_build.py +++ b/test/test_build.py @@ -52,7 +52,6 @@ def run(self): class _ParallelRunner(gokart.TaskOnKart[str]): def requires(self): return [_DummyTask(param=str(i)) for i in range(10)] - # return [_DummyTask(param=str(i), complete_check_at_run=i % 2 == 0) for i in range(10)] def run(self): self.dump('done') diff --git a/test/test_dependencies.py b/test/test_dependencies.py index ae9c06d5..25a2df8a 100644 --- a/test/test_dependencies.py +++ b/test/test_dependencies.py @@ -1,49 +1,49 @@ -# import luigi +import luigi -# import gokart -# from test.config import TEST_CONFIG_INI +import gokart +from test.config import TEST_CONFIG_INI -# class FooConfig(luigi.Config): -# name: str = luigi.Parameter() +class FooConfig(luigi.Config): + name: str = luigi.Parameter() -# class Foo: -# def __init__(self, name: str, version: str) -> None: -# self.name = name -# self.version = version +class Foo: + def __init__(self, name: str, version: str) -> None: + self.name = name + self.version = version -# class Bar: -# def __init__(self, foo: Foo) -> None: -# self.foo = foo +class Bar: + def __init__(self, foo: Foo) -> None: + self.foo = foo -# def build_foo(config: FooConfig, version: str) -> Foo: -# """`build_foo` function depends on `FooConfig` and `version` parameters. -# `version` parameter is passed from `DummyTask` in the resolving dependencies process. -# """ -# return Foo(name=config.name, version=version) +def build_foo(config: FooConfig, version: str) -> Foo: + """`build_foo` function depends on `FooConfig` and `version` parameters. + `version` parameter is passed from `DummyTask` in the resolving dependencies process. + """ + return Foo(name=config.name, version=version) -# def build_bar(foo: Foo = gokart.Depends(build_foo)) -> Bar: -# """NOTE: `build_bar` depends on the result of `build_foo` function.""" -# return Bar(foo=foo) +def build_bar(foo: Foo = gokart.Depends(build_foo)) -> Bar: + """NOTE: `build_bar` depends on the result of `build_foo` function.""" + return Bar(foo=foo) -# class DummyTask(gokart.TaskOnKart[None]): -# task_namespace = __name__ -# version: str = luigi.Parameter() +class DummyTask(gokart.TaskOnKart[None]): + task_namespace = __name__ + version: str = luigi.Parameter() -# def run(self, foo: Foo = gokart.Depends(build_foo), bar: Bar = gokart.Depends(build_bar)): -# assert isinstance(foo, Foo) -# assert isinstance(bar, Bar) -# assert foo.name == 'foo' -# assert foo.version == self.version -# assert bar.foo.name == 'foo' -# self.dump(None) + def run(self, foo: Foo = gokart.Depends(build_foo), bar: Bar = gokart.Depends(build_bar)): + assert isinstance(foo, Foo) + assert isinstance(bar, Bar) + assert foo.name == 'foo' + assert foo.version == self.version + assert bar.foo.name == 'foo' + self.dump(None) -# def test_success(): -# gokart.utils.add_config(str(TEST_CONFIG_INI)) -# gokart.build(DummyTask(version='1.0.0')) +def test_success(): + gokart.utils.add_config(str(TEST_CONFIG_INI)) + gokart.build(DummyTask(version='1.0.0'))