Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hironori Yamamoto committed Oct 8, 2024
1 parent 31f9a06 commit 88fce07
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
3 changes: 2 additions & 1 deletion gokart/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down
1 change: 0 additions & 1 deletion test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
66 changes: 33 additions & 33 deletions test/test_dependencies.py
Original file line number Diff line number Diff line change
@@ -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'))

0 comments on commit 88fce07

Please sign in to comment.