dagster-evidence 0.1.0__py3-none-any.whl
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.
- dagster_evidence/__init__.py +5 -0
- dagster_evidence/lib/__init__.py +1 -0
- dagster_evidence/lib/evidence_project.py +80 -0
- dagster_evidence-0.1.0.dist-info/METADATA +23 -0
- dagster_evidence-0.1.0.dist-info/RECORD +7 -0
- dagster_evidence-0.1.0.dist-info/WHEEL +5 -0
- dagster_evidence-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from dagster_evidence.lib.evidence_project import EvidenceProject
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
from tempfile import TemporaryDirectory
|
|
4
|
+
from dagster import Definitions, multi_asset
|
|
5
|
+
from dagster.components import (
|
|
6
|
+
Component,
|
|
7
|
+
ComponentLoadContext,
|
|
8
|
+
Resolvable,
|
|
9
|
+
)
|
|
10
|
+
from dagster.components.resolved.core_models import (
|
|
11
|
+
AssetPostProcessor,
|
|
12
|
+
ResolvedAssetSpec,
|
|
13
|
+
)
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
from typing import Optional, Sequence
|
|
16
|
+
import subprocess
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class EvidenceProject(Component, Resolvable):
|
|
21
|
+
"""Expose an Evidence.dev dashboard as a Dagster asset.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
This component assumes that you have already created an Evidence.dev project. Read [the Evidence docs](https://docs.evidence.dev/) for more information.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
project_path: The path to the Evidence.dev project.
|
|
28
|
+
asset: The asset to expose.
|
|
29
|
+
asset_post_processors: A list of asset post processors to apply to the asset.
|
|
30
|
+
deploy_command: The command to run to deploy the static assets somewhere. The $EVIDENCE_BUILD_PATH environment variable will be set to the path of the build output.
|
|
31
|
+
npm_executable: The executable to use to run npm commands.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
project_path: str
|
|
35
|
+
asset: ResolvedAssetSpec
|
|
36
|
+
asset_post_processors: Optional[Sequence[AssetPostProcessor]] = None
|
|
37
|
+
deploy_command: Optional[str] = None
|
|
38
|
+
npm_executable: str = "npm"
|
|
39
|
+
|
|
40
|
+
def build_defs(self, context: ComponentLoadContext) -> Definitions:
|
|
41
|
+
project_path = os.path.abspath(context.path / self.project_path)
|
|
42
|
+
|
|
43
|
+
def _run_cmd(cmd: Sequence[str]):
|
|
44
|
+
print(
|
|
45
|
+
f"{project_path}$ {' '.join(cmd)}",
|
|
46
|
+
file=sys.stderr,
|
|
47
|
+
)
|
|
48
|
+
subprocess.run(
|
|
49
|
+
cmd,
|
|
50
|
+
cwd=project_path,
|
|
51
|
+
check=True,
|
|
52
|
+
capture_output=False,
|
|
53
|
+
env=os.environ,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
@multi_asset(specs=[self.asset])
|
|
57
|
+
def evidence_project():
|
|
58
|
+
_run_cmd([self.npm_executable, "run", "sources"])
|
|
59
|
+
_run_cmd([self.npm_executable, "run", "build"])
|
|
60
|
+
|
|
61
|
+
if self.deploy_command is not None:
|
|
62
|
+
env = os.environ.copy()
|
|
63
|
+
env["EVIDENCE_BUILD_PATH"] = os.path.join(project_path, "build")
|
|
64
|
+
|
|
65
|
+
with TemporaryDirectory() as temp_dir:
|
|
66
|
+
print(f"{temp_dir}$ {self.deploy_command}", file=sys.stderr)
|
|
67
|
+
subprocess.run(
|
|
68
|
+
self.deploy_command,
|
|
69
|
+
cwd=temp_dir,
|
|
70
|
+
check=True,
|
|
71
|
+
capture_output=False,
|
|
72
|
+
env=env,
|
|
73
|
+
shell=True,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
defs = Definitions(assets=[evidence_project])
|
|
77
|
+
for post_processor in self.asset_post_processors or []:
|
|
78
|
+
defs = post_processor(defs)
|
|
79
|
+
|
|
80
|
+
return defs
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dagster-evidence
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dagster integration with evidence.dev
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: dagster>=1.10.9
|
|
8
|
+
|
|
9
|
+
# dagster-evidence
|
|
10
|
+
|
|
11
|
+
`dagster-evidence` provides a Dagster Component that integrates with [evidence](https://evidence.dev/), an open-source tool for building data apps.
|
|
12
|
+
|
|
13
|
+
## Test
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
make test
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Build
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
make build
|
|
23
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
dagster_evidence/__init__.py,sha256=O0685efzy-eo9SaaMuPO4Y-oM1GOJpesHfcplB4gyek,148
|
|
2
|
+
dagster_evidence/lib/__init__.py,sha256=pLil7ph_5C5j_WEVUgfU91u9y-cg7OaX4AKE-9elWNo,66
|
|
3
|
+
dagster_evidence/lib/evidence_project.py,sha256=7XHGlekPKeCYJgPa602DF8MPUDSvD_PrIi6v7p_a7Bc,2785
|
|
4
|
+
dagster_evidence-0.1.0.dist-info/METADATA,sha256=9iA7paX1eNiiT9UTSlQPeoPkxjCO7UTszlyd4ndmnRM,432
|
|
5
|
+
dagster_evidence-0.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
6
|
+
dagster_evidence-0.1.0.dist-info/top_level.txt,sha256=YAZVTuvV8f7bWYwERV2uGnMQj93E4Vq3KHdsGPpN6IY,17
|
|
7
|
+
dagster_evidence-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dagster_evidence
|