-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hironori Yamamoto
committed
Oct 8, 2024
1 parent
31f9a06
commit 88fce07
Showing
3 changed files
with
35 additions
and
35 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
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')) |