datatailr 0.1.5__tar.gz → 0.1.79__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.
Potentially problematic release.
This version of datatailr might be problematic. Click here for more details.
- datatailr-0.1.79/PKG-INFO +154 -0
- datatailr-0.1.79/README.md +117 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/pyproject.toml +19 -3
- datatailr-0.1.79/setup.py +21 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/__init__.py +15 -35
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/acl.py +40 -8
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/blob.py +26 -15
- datatailr-0.1.79/src/datatailr/build/image.py +162 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/dt_json.py +32 -0
- datatailr-0.1.79/src/datatailr/errors.py +27 -0
- datatailr-0.1.79/src/datatailr/excel/__init__.py +34 -0
- datatailr-0.1.79/src/datatailr/excel/addin.py +201 -0
- datatailr-0.1.79/src/datatailr/excel/stubs.py +37 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/group.py +19 -13
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/logging.py +59 -17
- datatailr-0.1.79/src/datatailr/scheduler/__init__.py +60 -0
- datatailr-0.1.79/src/datatailr/scheduler/arguments_cache.py +168 -0
- datatailr-0.1.79/src/datatailr/scheduler/base.py +466 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/scheduler/batch.py +240 -21
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/scheduler/batch_decorator.py +66 -27
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/scheduler/constants.py +2 -2
- datatailr-0.1.79/src/datatailr/scheduler/job.py +112 -0
- datatailr-0.1.79/src/datatailr/scheduler/schedule.py +117 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/scheduler/utils.py +3 -1
- datatailr-0.1.79/src/datatailr/scheduler/workflow.py +84 -0
- datatailr-0.1.79/src/datatailr/tag.py +35 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/user.py +27 -17
- datatailr-0.1.79/src/datatailr/utils.py +67 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/wrapper.py +15 -13
- datatailr-0.1.79/src/datatailr.egg-info/PKG-INFO +154 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr.egg-info/SOURCES.txt +12 -3
- datatailr-0.1.79/src/datatailr.egg-info/entry_points.txt +6 -0
- datatailr-0.1.79/src/datatailr.egg-info/requires.txt +15 -0
- datatailr-0.1.79/src/datatailr.egg-info/top_level.txt +1 -0
- datatailr-0.1.79/src/sbin/datatailr_run.py +324 -0
- datatailr-0.1.79/src/sbin/datatailr_run_app.py +52 -0
- datatailr-0.1.5/src/sbin/run_job.py → datatailr-0.1.79/src/sbin/datatailr_run_batch.py +5 -20
- datatailr-0.1.79/src/sbin/datatailr_run_excel.py +42 -0
- datatailr-0.1.79/src/sbin/datatailr_run_service.py +36 -0
- datatailr-0.1.5/PKG-INFO +0 -75
- datatailr-0.1.5/README.md +0 -45
- datatailr-0.1.5/setup.py +0 -10
- datatailr-0.1.5/src/datatailr/build/image.py +0 -87
- datatailr-0.1.5/src/datatailr/errors.py +0 -10
- datatailr-0.1.5/src/datatailr/scheduler/__init__.py +0 -38
- datatailr-0.1.5/src/datatailr/scheduler/arguments_cache.py +0 -126
- datatailr-0.1.5/src/datatailr/scheduler/base.py +0 -245
- datatailr-0.1.5/src/datatailr/utils.py +0 -35
- datatailr-0.1.5/src/datatailr.egg-info/PKG-INFO +0 -75
- datatailr-0.1.5/src/datatailr.egg-info/entry_points.txt +0 -2
- datatailr-0.1.5/src/datatailr.egg-info/requires.txt +0 -8
- datatailr-0.1.5/src/datatailr.egg-info/top_level.txt +0 -2
- datatailr-0.1.5/src/test_module/__init__.py +0 -17
- datatailr-0.1.5/src/test_module/test_submodule.py +0 -38
- {datatailr-0.1.5 → datatailr-0.1.79}/LICENSE +0 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/setup.cfg +0 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/build/__init__.py +0 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr/version.py +0 -0
- {datatailr-0.1.5 → datatailr-0.1.79}/src/datatailr.egg-info/dependency_links.txt +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: datatailr
|
|
3
|
+
Version: 0.1.79
|
|
4
|
+
Summary: Ready-to-Use Platform That Drives Business Insights
|
|
5
|
+
Author-email: Datatailr <info@datatailr.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: homepage, https://www.datatailr.com/
|
|
8
|
+
Project-URL: documentation, https://docs.datatailr.com/
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Environment :: Console
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: ruff; extra == "dev"
|
|
24
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy; extra == "dev"
|
|
26
|
+
Requires-Dist: types-setuptools; extra == "dev"
|
|
27
|
+
Requires-Dist: toml; extra == "dev"
|
|
28
|
+
Requires-Dist: coverage; extra == "dev"
|
|
29
|
+
Requires-Dist: sphinx-rtd-theme; extra == "dev"
|
|
30
|
+
Requires-Dist: sphinx; extra == "dev"
|
|
31
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == "dev"
|
|
32
|
+
Requires-Dist: sphinx-autosummary; extra == "dev"
|
|
33
|
+
Requires-Dist: sphinx-design; extra == "dev"
|
|
34
|
+
Requires-Dist: sphinx-copybutton; extra == "dev"
|
|
35
|
+
Requires-Dist: myst-parser; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
<div style="text-align: center;">
|
|
39
|
+
<a href="https://www.datatailr.com/" target="_blank">
|
|
40
|
+
<img src="https://s3.eu-west-1.amazonaws.com/datatailr.com/assets/datatailr-logo.svg" alt="Datatailr Logo" />
|
|
41
|
+
</a>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
**Datatailr empowers your team to streamline analytics and data workflows
|
|
47
|
+
from idea to production without infrastructure hurdles.**
|
|
48
|
+
|
|
49
|
+
# What is Datatailr?
|
|
50
|
+
|
|
51
|
+
Datatailr is a platform that simplifies the process of building and deploying data applications.
|
|
52
|
+
|
|
53
|
+
It makes it easier to run and maintain large-scale data processing and analytics workloads.
|
|
54
|
+
|
|
55
|
+
## What is this package?
|
|
56
|
+
This is the Python package for Datatailr, which allows you to interact with the Datatailr platform.
|
|
57
|
+
|
|
58
|
+
It provides the tools to build, deploy, and manage batch jobs, data pipelines, services and analytics applications.
|
|
59
|
+
|
|
60
|
+
Datatailr manages the underlying infrastructure so your applications can be deployed in an easy, secure and scalable way.
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
### Installing the `dt` command line tool
|
|
65
|
+
Before you can use the Datatailr Python package, you need to install the `dt` command line tool.
|
|
66
|
+
**[INSTALLATION INSTRUCTIONS FOR DATATAILR GO HERE]**
|
|
67
|
+
|
|
68
|
+
### Installing the Python package
|
|
69
|
+
You can install the Datatailr Python package using pip:
|
|
70
|
+
```bash
|
|
71
|
+
pip install datatailr
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Testing the installation
|
|
75
|
+
```python
|
|
76
|
+
import datatailr
|
|
77
|
+
|
|
78
|
+
print(datatailr.__version__)
|
|
79
|
+
print(datatailr.__provider__)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Quickstart
|
|
84
|
+
The following example shows how to create a simple data pipeline using the Datatailr Python package.
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from datatailr import workflow, task
|
|
88
|
+
|
|
89
|
+
@task()
|
|
90
|
+
def func_no_args() -> str:
|
|
91
|
+
return "no_args"
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@task()
|
|
95
|
+
def func_with_args(a: int, b: float) -> str:
|
|
96
|
+
return f"args: {a}, {b}"
|
|
97
|
+
|
|
98
|
+
@workflow(name="MY test DAG")
|
|
99
|
+
def my_workflow():
|
|
100
|
+
for n in range(2):
|
|
101
|
+
res1 = func_no_args().alias(f"func_{n}")
|
|
102
|
+
res2 = func_with_args(1, res1).alias(f"func_with_args_{n}")
|
|
103
|
+
my_workflow(local_run=True)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Running this code will create a graph of jobs and execute it.
|
|
107
|
+
Each node on the graph represents a job, which in turn is a call to a function decorated with `@task()`.
|
|
108
|
+
|
|
109
|
+
Since this is a local run then the execution of each node will happen sequentially in the same process.
|
|
110
|
+
|
|
111
|
+
To take advantage of the datatailr platform and execute the graph at scale, you can run it using the job scheduler as presented in the next section.
|
|
112
|
+
|
|
113
|
+
## Execution at Scale
|
|
114
|
+
To execute the graph at scale, you can use the Datatailr job scheduler. This allows you to run your jobs in parallel, taking advantage of the underlying infrastructure.
|
|
115
|
+
|
|
116
|
+
You will first need to separate your function definitions from the DAG definition. This means you should define your functions as a separate module, which can be imported into the DAG definition.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
# my_module.py
|
|
121
|
+
|
|
122
|
+
from datatailr import task
|
|
123
|
+
|
|
124
|
+
@task()
|
|
125
|
+
def func_no_args() -> str:
|
|
126
|
+
return "no_args"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@task()
|
|
130
|
+
def func_with_args(a: int, b: float) -> str:
|
|
131
|
+
return f"args: {a}, {b}"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
To use these functions in a batch job, you just need to import them and run in a DAG context:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from my_module import func_no_args, func_with_args
|
|
138
|
+
from datatailr import workflow
|
|
139
|
+
|
|
140
|
+
@workflow(name="MY test DAG")
|
|
141
|
+
def my_workflow():
|
|
142
|
+
for n in range(2):
|
|
143
|
+
res1 = func_no_args().alias(f"func_{n}")
|
|
144
|
+
res2 = func_with_args(1, res1).alias(f"func_with_args_{n}")
|
|
145
|
+
|
|
146
|
+
schedule = Schedule(at_hours=0)
|
|
147
|
+
my_workflow(schedule=schedule)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
This will submit the entire workflow for execution, and the scheduler will take care of running the jobs in parallel and managing the resources.
|
|
151
|
+
The workflow in the example above will be scheduled to run daily at 00:00.
|
|
152
|
+
|
|
153
|
+
___
|
|
154
|
+
Visit [our website](https://www.datatailr.com/) for more!
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<div style="text-align: center;">
|
|
2
|
+
<a href="https://www.datatailr.com/" target="_blank">
|
|
3
|
+
<img src="https://s3.eu-west-1.amazonaws.com/datatailr.com/assets/datatailr-logo.svg" alt="Datatailr Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
**Datatailr empowers your team to streamline analytics and data workflows
|
|
10
|
+
from idea to production without infrastructure hurdles.**
|
|
11
|
+
|
|
12
|
+
# What is Datatailr?
|
|
13
|
+
|
|
14
|
+
Datatailr is a platform that simplifies the process of building and deploying data applications.
|
|
15
|
+
|
|
16
|
+
It makes it easier to run and maintain large-scale data processing and analytics workloads.
|
|
17
|
+
|
|
18
|
+
## What is this package?
|
|
19
|
+
This is the Python package for Datatailr, which allows you to interact with the Datatailr platform.
|
|
20
|
+
|
|
21
|
+
It provides the tools to build, deploy, and manage batch jobs, data pipelines, services and analytics applications.
|
|
22
|
+
|
|
23
|
+
Datatailr manages the underlying infrastructure so your applications can be deployed in an easy, secure and scalable way.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### Installing the `dt` command line tool
|
|
28
|
+
Before you can use the Datatailr Python package, you need to install the `dt` command line tool.
|
|
29
|
+
**[INSTALLATION INSTRUCTIONS FOR DATATAILR GO HERE]**
|
|
30
|
+
|
|
31
|
+
### Installing the Python package
|
|
32
|
+
You can install the Datatailr Python package using pip:
|
|
33
|
+
```bash
|
|
34
|
+
pip install datatailr
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Testing the installation
|
|
38
|
+
```python
|
|
39
|
+
import datatailr
|
|
40
|
+
|
|
41
|
+
print(datatailr.__version__)
|
|
42
|
+
print(datatailr.__provider__)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Quickstart
|
|
47
|
+
The following example shows how to create a simple data pipeline using the Datatailr Python package.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from datatailr import workflow, task
|
|
51
|
+
|
|
52
|
+
@task()
|
|
53
|
+
def func_no_args() -> str:
|
|
54
|
+
return "no_args"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@task()
|
|
58
|
+
def func_with_args(a: int, b: float) -> str:
|
|
59
|
+
return f"args: {a}, {b}"
|
|
60
|
+
|
|
61
|
+
@workflow(name="MY test DAG")
|
|
62
|
+
def my_workflow():
|
|
63
|
+
for n in range(2):
|
|
64
|
+
res1 = func_no_args().alias(f"func_{n}")
|
|
65
|
+
res2 = func_with_args(1, res1).alias(f"func_with_args_{n}")
|
|
66
|
+
my_workflow(local_run=True)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Running this code will create a graph of jobs and execute it.
|
|
70
|
+
Each node on the graph represents a job, which in turn is a call to a function decorated with `@task()`.
|
|
71
|
+
|
|
72
|
+
Since this is a local run then the execution of each node will happen sequentially in the same process.
|
|
73
|
+
|
|
74
|
+
To take advantage of the datatailr platform and execute the graph at scale, you can run it using the job scheduler as presented in the next section.
|
|
75
|
+
|
|
76
|
+
## Execution at Scale
|
|
77
|
+
To execute the graph at scale, you can use the Datatailr job scheduler. This allows you to run your jobs in parallel, taking advantage of the underlying infrastructure.
|
|
78
|
+
|
|
79
|
+
You will first need to separate your function definitions from the DAG definition. This means you should define your functions as a separate module, which can be imported into the DAG definition.
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
# my_module.py
|
|
84
|
+
|
|
85
|
+
from datatailr import task
|
|
86
|
+
|
|
87
|
+
@task()
|
|
88
|
+
def func_no_args() -> str:
|
|
89
|
+
return "no_args"
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@task()
|
|
93
|
+
def func_with_args(a: int, b: float) -> str:
|
|
94
|
+
return f"args: {a}, {b}"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
To use these functions in a batch job, you just need to import them and run in a DAG context:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from my_module import func_no_args, func_with_args
|
|
101
|
+
from datatailr import workflow
|
|
102
|
+
|
|
103
|
+
@workflow(name="MY test DAG")
|
|
104
|
+
def my_workflow():
|
|
105
|
+
for n in range(2):
|
|
106
|
+
res1 = func_no_args().alias(f"func_{n}")
|
|
107
|
+
res2 = func_with_args(1, res1).alias(f"func_with_args_{n}")
|
|
108
|
+
|
|
109
|
+
schedule = Schedule(at_hours=0)
|
|
110
|
+
my_workflow(schedule=schedule)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
This will submit the entire workflow for execution, and the scheduler will take care of running the jobs in parallel and managing the resources.
|
|
114
|
+
The workflow in the example above will be scheduled to run daily at 00:00.
|
|
115
|
+
|
|
116
|
+
___
|
|
117
|
+
Visit [our website](https://www.datatailr.com/) for more!
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools
|
|
2
|
+
requires = ["setuptools", "wheel", "toml"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "datatailr"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.79"
|
|
8
8
|
description = "Ready-to-Use Platform That Drives Business Insights"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -34,7 +34,11 @@ homepage = "https://www.datatailr.com/"
|
|
|
34
34
|
documentation = "https://docs.datatailr.com/"
|
|
35
35
|
|
|
36
36
|
[project.scripts]
|
|
37
|
-
|
|
37
|
+
datatailr_run = "datatailr.sbin.datatailr_run:main"
|
|
38
|
+
datatailr_run_batch = "datatailr.sbin.datatailr_run_batch:run"
|
|
39
|
+
datatailr_run_app = "datatailr.sbin.datatailr_run_app:run"
|
|
40
|
+
datatailr_run_excel = "datatailr.sbin.datatailr_run_excel:run"
|
|
41
|
+
datatailr_run_service = "datatailr.sbin.datatailr_run_service:run"
|
|
38
42
|
|
|
39
43
|
[project.optional-dependencies]
|
|
40
44
|
dev = [
|
|
@@ -44,13 +48,25 @@ dev = [
|
|
|
44
48
|
"types-setuptools",
|
|
45
49
|
"toml",
|
|
46
50
|
"coverage",
|
|
51
|
+
"sphinx-rtd-theme",
|
|
52
|
+
"sphinx",
|
|
53
|
+
"sphinx-autodoc-typehints",
|
|
54
|
+
"sphinx-autosummary",
|
|
55
|
+
"sphinx-design",
|
|
56
|
+
"sphinx-copybutton",
|
|
57
|
+
"myst-parser"
|
|
47
58
|
]
|
|
48
59
|
|
|
60
|
+
[tool.coverage.run]
|
|
61
|
+
branch = true
|
|
62
|
+
source = ["./src/datatailr"]
|
|
63
|
+
|
|
49
64
|
[tool.ruff]
|
|
50
65
|
src = [
|
|
51
66
|
"src",
|
|
52
67
|
"../../tests/src/python"
|
|
53
68
|
]
|
|
69
|
+
|
|
54
70
|
lint.ignore = ["F841"]
|
|
55
71
|
show-fixes = true
|
|
56
72
|
fix = true
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from datatailr import __version__ # type: ignore
|
|
2
|
+
from setuptools import find_packages, setup
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name="datatailr",
|
|
6
|
+
version=__version__,
|
|
7
|
+
packages=find_packages(where="src", exclude=["test_module", "test_module.*"]),
|
|
8
|
+
package_dir={"": "src"},
|
|
9
|
+
data_files=[
|
|
10
|
+
(
|
|
11
|
+
"/datatailr/sbin",
|
|
12
|
+
[
|
|
13
|
+
"src/sbin/datatailr_run.py",
|
|
14
|
+
"src/sbin/datatailr_run_batch.py",
|
|
15
|
+
"src/sbin/datatailr_run_app.py",
|
|
16
|
+
"src/sbin/datatailr_run_excel.py",
|
|
17
|
+
"src/sbin/datatailr_run_service.py",
|
|
18
|
+
],
|
|
19
|
+
)
|
|
20
|
+
],
|
|
21
|
+
)
|
|
@@ -8,32 +8,22 @@
|
|
|
8
8
|
# of this file, in parts or full, via any medium is strictly prohibited.
|
|
9
9
|
# *************************************************************************
|
|
10
10
|
|
|
11
|
-
from datatailr.wrapper import
|
|
12
|
-
dt__Blob,
|
|
13
|
-
dt__Dns,
|
|
14
|
-
dt__Email,
|
|
15
|
-
dt__Group,
|
|
16
|
-
dt__Job,
|
|
17
|
-
dt__Kv,
|
|
18
|
-
dt__Log,
|
|
19
|
-
dt__Node,
|
|
20
|
-
dt__Registry,
|
|
21
|
-
dt__Service,
|
|
22
|
-
dt__Settings,
|
|
23
|
-
dt__Sms,
|
|
24
|
-
dt__System,
|
|
25
|
-
dt__Tag,
|
|
26
|
-
dt__User,
|
|
27
|
-
mock_cli_tool,
|
|
28
|
-
)
|
|
11
|
+
from datatailr.wrapper import dt__System, mock_cli_tool
|
|
29
12
|
from datatailr.group import Group
|
|
30
13
|
from datatailr.user import User
|
|
31
14
|
from datatailr.acl import ACL
|
|
32
15
|
from datatailr.blob import Blob
|
|
33
16
|
from datatailr.build import Image
|
|
34
|
-
from datatailr.dt_json import dt_json
|
|
35
17
|
from datatailr.utils import Environment, is_dt_installed
|
|
36
18
|
from datatailr.version import __version__
|
|
19
|
+
from datatailr.scheduler import (
|
|
20
|
+
App,
|
|
21
|
+
Service,
|
|
22
|
+
ExcelAddin,
|
|
23
|
+
workflow,
|
|
24
|
+
task,
|
|
25
|
+
set_allow_unsafe_scheduling,
|
|
26
|
+
)
|
|
37
27
|
|
|
38
28
|
system = dt__System()
|
|
39
29
|
if isinstance(system, mock_cli_tool):
|
|
@@ -50,21 +40,11 @@ __all__ = [
|
|
|
50
40
|
"User",
|
|
51
41
|
"__version__",
|
|
52
42
|
"__provider__",
|
|
53
|
-
"dt__Blob",
|
|
54
|
-
"dt__Dns",
|
|
55
|
-
"dt__Email",
|
|
56
|
-
"dt__Group",
|
|
57
|
-
"dt__Job",
|
|
58
|
-
"dt__Kv",
|
|
59
|
-
"dt__Log",
|
|
60
|
-
"dt__Node",
|
|
61
|
-
"dt__Registry",
|
|
62
|
-
"dt__Service",
|
|
63
|
-
"dt__Settings",
|
|
64
|
-
"dt__Sms",
|
|
65
|
-
"dt__System",
|
|
66
|
-
"dt__Tag",
|
|
67
|
-
"dt__User",
|
|
68
|
-
"dt_json",
|
|
69
43
|
"is_dt_installed",
|
|
44
|
+
"App",
|
|
45
|
+
"Service",
|
|
46
|
+
"ExcelAddin",
|
|
47
|
+
"workflow",
|
|
48
|
+
"task",
|
|
49
|
+
"set_allow_unsafe_scheduling",
|
|
70
50
|
]
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
# of this file, in parts or full, via any medium is strictly prohibited.
|
|
9
9
|
# *************************************************************************
|
|
10
10
|
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
11
13
|
import json
|
|
12
14
|
from typing import List, Optional, Union
|
|
13
15
|
|
|
@@ -23,15 +25,15 @@ class ACL:
|
|
|
23
25
|
self,
|
|
24
26
|
user: Union[User, str],
|
|
25
27
|
group: Optional[Union[Group, str]] = None,
|
|
26
|
-
permissions: Optional[List[str]] = None,
|
|
28
|
+
permissions: Optional[List[str] | str] = None,
|
|
27
29
|
):
|
|
28
30
|
if user is None:
|
|
29
31
|
user = User.signed_user()
|
|
30
32
|
self.user = user if isinstance(user, User) else User.get(user)
|
|
31
|
-
if
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if group is None:
|
|
34
|
+
group = self.user.primary_group
|
|
35
|
+
group = group if isinstance(group, Group) else Group.get(str(group))
|
|
36
|
+
self.group = group
|
|
35
37
|
self.permissions = permissions or "rwr---"
|
|
36
38
|
|
|
37
39
|
self.__group_can_read = False
|
|
@@ -40,9 +42,9 @@ class ACL:
|
|
|
40
42
|
self.__user_can_write = False
|
|
41
43
|
self.__world_readable = False
|
|
42
44
|
|
|
43
|
-
self.
|
|
45
|
+
self.__parse_permissions_string()
|
|
44
46
|
|
|
45
|
-
def
|
|
47
|
+
def __parse_permissions_string(self):
|
|
46
48
|
"""
|
|
47
49
|
Parse the permissions and set the corresponding flags.
|
|
48
50
|
"""
|
|
@@ -59,6 +61,19 @@ class ACL:
|
|
|
59
61
|
self.__world_readable = self.permissions[4] == "r"
|
|
60
62
|
self.__world_writable = self.permissions[5] == "w"
|
|
61
63
|
|
|
64
|
+
def _set_permissions_string(self):
|
|
65
|
+
"""
|
|
66
|
+
Set the permissions string based on the current flags.
|
|
67
|
+
"""
|
|
68
|
+
self.permissions = (
|
|
69
|
+
f"{'r' if self.__user_can_read else '-'}"
|
|
70
|
+
f"{'w' if self.__user_can_write else '-'}"
|
|
71
|
+
f"{'r' if self.__group_can_read else '-'}"
|
|
72
|
+
f"{'w' if self.__group_can_write else '-'}"
|
|
73
|
+
f"{'r' if self.__world_readable else '-'}"
|
|
74
|
+
f"{'w' if self.__world_writable else '-'}"
|
|
75
|
+
)
|
|
76
|
+
|
|
62
77
|
def __repr__(self):
|
|
63
78
|
return (
|
|
64
79
|
f"ACL(user={self.user}, group={self.group}, permissions={self.permissions})"
|
|
@@ -67,7 +82,7 @@ class ACL:
|
|
|
67
82
|
def to_dict(self):
|
|
68
83
|
return {
|
|
69
84
|
"user": self.user.name,
|
|
70
|
-
"group": self.group.name if self.group else
|
|
85
|
+
"group": self.group.name if self.group else "dtusers",
|
|
71
86
|
"group_can_read": self.__group_can_read,
|
|
72
87
|
"group_can_write": self.__group_can_write,
|
|
73
88
|
"user_can_read": self.__user_can_read,
|
|
@@ -76,5 +91,22 @@ class ACL:
|
|
|
76
91
|
"world_writable": self.__world_writable,
|
|
77
92
|
}
|
|
78
93
|
|
|
94
|
+
@classmethod
|
|
95
|
+
def from_dict(cls, acl_dict: dict) -> ACL:
|
|
96
|
+
"""
|
|
97
|
+
Create an ACL instance from a dictionary.
|
|
98
|
+
"""
|
|
99
|
+
user = User(acl_dict["user"])
|
|
100
|
+
group = Group.get(acl_dict["group"]) if "group" in acl_dict else None
|
|
101
|
+
acl = cls(user=user, group=group)
|
|
102
|
+
acl.__group_can_read = acl_dict.get("group_can_read", False)
|
|
103
|
+
acl.__group_can_write = acl_dict.get("group_can_write", False)
|
|
104
|
+
acl.__user_can_read = acl_dict.get("user_can_read", False)
|
|
105
|
+
acl.__user_can_write = acl_dict.get("user_can_write", False)
|
|
106
|
+
acl.__world_readable = acl_dict.get("world_readable", False)
|
|
107
|
+
acl.__world_writable = acl_dict.get("world_writable", False)
|
|
108
|
+
acl._set_permissions_string()
|
|
109
|
+
return acl
|
|
110
|
+
|
|
79
111
|
def to_json(self):
|
|
80
112
|
return json.dumps(self.to_dict())
|
|
@@ -10,14 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
|
+
import os
|
|
13
14
|
import tempfile
|
|
14
15
|
|
|
15
|
-
from datatailr import dt__Blob
|
|
16
|
+
from datatailr.wrapper import dt__Blob
|
|
16
17
|
|
|
18
|
+
# Datatailr Blob API Client
|
|
19
|
+
__client__ = dt__Blob()
|
|
20
|
+
__user__ = os.getenv("USER", "root")
|
|
17
21
|
|
|
18
|
-
class Blob:
|
|
19
|
-
__blob_storage__ = dt__Blob()
|
|
20
22
|
|
|
23
|
+
class Blob:
|
|
21
24
|
def ls(self, path: str) -> list[str]:
|
|
22
25
|
"""
|
|
23
26
|
List files in the specified path.
|
|
@@ -25,7 +28,7 @@ class Blob:
|
|
|
25
28
|
:param path: The path to list files from.
|
|
26
29
|
:return: A list of file names in the specified path.
|
|
27
30
|
"""
|
|
28
|
-
return
|
|
31
|
+
return __client__.ls(path)
|
|
29
32
|
|
|
30
33
|
def get_file(self, name: str, path: str):
|
|
31
34
|
"""
|
|
@@ -35,7 +38,7 @@ class Blob:
|
|
|
35
38
|
name (str): The name of the blob to retrieve.
|
|
36
39
|
path (str): The path to store the blob as a file.
|
|
37
40
|
"""
|
|
38
|
-
return
|
|
41
|
+
return __client__.cp(f"blob://{name}", path)
|
|
39
42
|
|
|
40
43
|
def put_file(self, name: str, path: str):
|
|
41
44
|
"""
|
|
@@ -45,7 +48,7 @@ class Blob:
|
|
|
45
48
|
name (str): The name of the blob to create.
|
|
46
49
|
path (str): The path of the local file to copy.
|
|
47
50
|
"""
|
|
48
|
-
return
|
|
51
|
+
return __client__.cp(path, f"blob://{name}")
|
|
49
52
|
|
|
50
53
|
def exists(self, name: str) -> bool:
|
|
51
54
|
"""
|
|
@@ -57,7 +60,7 @@ class Blob:
|
|
|
57
60
|
Returns:
|
|
58
61
|
bool: True if the blob exists, False otherwise.
|
|
59
62
|
"""
|
|
60
|
-
return
|
|
63
|
+
return __client__.exists(name)
|
|
61
64
|
|
|
62
65
|
def delete(self, name: str):
|
|
63
66
|
"""
|
|
@@ -66,7 +69,7 @@ class Blob:
|
|
|
66
69
|
Args:
|
|
67
70
|
name (str): The name of the blob to delete.
|
|
68
71
|
"""
|
|
69
|
-
return
|
|
72
|
+
return __client__.rm(name)
|
|
70
73
|
|
|
71
74
|
def get_blob(self, name: str):
|
|
72
75
|
"""
|
|
@@ -80,10 +83,15 @@ class Blob:
|
|
|
80
83
|
"""
|
|
81
84
|
# Since direct reading and writting of blobs is not implemented yet, we are using a temporary file.
|
|
82
85
|
# This is a workaround to allow reading the blob content directly from the blob storage.
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
temp_dir = f"/home/{__user__}/tmp"
|
|
87
|
+
if not os.path.exists(temp_dir):
|
|
88
|
+
temp_dir = "/tmp"
|
|
89
|
+
else:
|
|
90
|
+
temp_dir += "/.dt"
|
|
91
|
+
os.makedirs(temp_dir, exist_ok=True)
|
|
92
|
+
with tempfile.NamedTemporaryFile(dir=temp_dir, delete=True) as temp_file:
|
|
85
93
|
self.get_file(name, temp_file.name)
|
|
86
|
-
with open(temp_file.name, "
|
|
94
|
+
with open(temp_file.name, "r") as f:
|
|
87
95
|
return f.read()
|
|
88
96
|
|
|
89
97
|
def put_blob(self, name: str, blob):
|
|
@@ -96,8 +104,11 @@ class Blob:
|
|
|
96
104
|
"""
|
|
97
105
|
# Since direct reading and writting of blobs is not implemented yet, we are using a temporary file.
|
|
98
106
|
# This is a workaround to allow writing the blob content directly to the blob storage.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
with tempfile.NamedTemporaryFile(delete=True) as temp_file:
|
|
108
|
+
if isinstance(blob, bytes):
|
|
109
|
+
with open(temp_file.name, "wb") as f:
|
|
110
|
+
f.write(blob)
|
|
111
|
+
else:
|
|
112
|
+
with open(temp_file.name, "w") as f:
|
|
113
|
+
f.write(blob)
|
|
103
114
|
self.put_file(name, temp_file.name)
|