tinyfan 0.2.3__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tinyfan-0.2.3 → tinyfan-0.2.4}/PKG-INFO +1 -1
- {tinyfan-0.2.3 → tinyfan-0.2.4}/pyproject.toml +1 -1
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/resources/base.py +2 -1
- tinyfan-0.2.4/tests/test_config.py +60 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/uv.lock +1 -1
- {tinyfan-0.2.3 → tinyfan-0.2.4}/.github/workflows/publish.yml +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/.gitignore +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/.python-version +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/README.md +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/README.md +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/configmap.yaml +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/configs.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/getting-started.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/packaged/.python-version +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/packaged/Dockerfile +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/packaged/README.md +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/packaged/pyproject.toml +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/packaged/src/tinyfan_examples_packaged/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/packaged/src/tinyfan_examples_packaged/asset.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/resource.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/examples/secret.yaml +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/argo_typing.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/cli.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/codegen.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/config.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/dagviz.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/flow.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/flowrundata.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/py.typed +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/resources/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/stores/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/stores/base.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/stores/bigquery.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/stores/gcs_pickle.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/stores/naive.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/utils/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/utils/embed.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/utils/exjson.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/utils/merge.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/utils/typing.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/src/tinyfan/utils/yaml.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/codegen_samples/directory/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/codegen_samples/directory/asset.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/codegen_samples/directory/asset2.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/codegen_samples/singlefile.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/conftest.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/helpers.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/openapi2jsonschema.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/test_codegen.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/test_decorators.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/utils/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/utils/embed_samples/directory/__init__.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/utils/embed_samples/directory/dep.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/utils/embed_samples/singlefile.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/utils/test_embed.py +0 -0
- {tinyfan-0.2.3 → tinyfan-0.2.4}/tests/utils/test_exjson.py +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from ..config import Config, ConfigValue
|
|
2
|
+
import inspect
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class ResourceBase:
|
|
5
6
|
def get_refs(self) -> set[Config | ConfigValue]:
|
|
6
7
|
refs = set()
|
|
7
|
-
for _, value in
|
|
8
|
+
for _, value in inspect.getmembers(self):
|
|
8
9
|
if isinstance(value, (Config, ConfigValue)): # or a common base 'Reference'
|
|
9
10
|
refs.add(value)
|
|
10
11
|
elif isinstance(value, ResourceBase):
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from tinyfan import Flow, asset, ResourceBase, ConfigMapRef, ConfigMapKeyRef, SecretRef, SecretKeyRef
|
|
2
|
+
from tinyfan.flow import FLOW_REGISTER
|
|
3
|
+
from tinyfan.codegen import codegen
|
|
4
|
+
from typing import Generator
|
|
5
|
+
from unittest import mock
|
|
6
|
+
import pytest
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# type: ignore
|
|
11
|
+
@pytest.fixture()
|
|
12
|
+
def sample_flow() -> Generator:
|
|
13
|
+
class Resource(ResourceBase):
|
|
14
|
+
cm = ConfigMapRef("cm")
|
|
15
|
+
cm_key = ConfigMapKeyRef("cm", "key")
|
|
16
|
+
cm_default = ConfigMapKeyRef("cm", "non_key", "default")
|
|
17
|
+
sec = SecretRef("secret")
|
|
18
|
+
sec_key = SecretKeyRef("secret", "key")
|
|
19
|
+
sec_default = SecretKeyRef("secret", "non_key", "default")
|
|
20
|
+
|
|
21
|
+
flow: Flow = Flow(
|
|
22
|
+
"test",
|
|
23
|
+
resources={
|
|
24
|
+
"res": Resource(),
|
|
25
|
+
},
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
@asset(flow=flow, schedule="@daily")
|
|
29
|
+
def test_asset(res: Resource): # type: ignore
|
|
30
|
+
return (
|
|
31
|
+
res.cm.get("key"),
|
|
32
|
+
res.cm_key.get_value(),
|
|
33
|
+
res.cm_default.get_value(),
|
|
34
|
+
res.sec.get("key"),
|
|
35
|
+
res.sec_key.get_value(),
|
|
36
|
+
res.sec_default.get_value(),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
yield flow
|
|
40
|
+
FLOW_REGISTER.clear()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# HACK IT: skip it at this stage. too tired.
|
|
44
|
+
def test_resource_config_codgen(validate_crds, sample_flow):
|
|
45
|
+
res = codegen(flow=sample_flow)
|
|
46
|
+
validate_crds(res)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_resource_config_run(sample_flow: Flow):
|
|
50
|
+
env = {
|
|
51
|
+
"TINYFAN_CM__cm__key": "cmkey",
|
|
52
|
+
"TINYFAN_SC__secret__key": "sekey",
|
|
53
|
+
"key": "key",
|
|
54
|
+
}
|
|
55
|
+
with mock.patch.dict(os.environ, env):
|
|
56
|
+
_ = codegen(flow=sample_flow)
|
|
57
|
+
asset = list(sample_flow.assets.values())[0]
|
|
58
|
+
actual, _ = asset.run()
|
|
59
|
+
expected = ("key", "cmkey", "default", "key", "sekey", "default")
|
|
60
|
+
assert actual == expected
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|