datatailr 0.1.6__py3-none-any.whl → 0.1.8__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.

Potentially problematic release.


This version of datatailr might be problematic. Click here for more details.

datatailr/user.py CHANGED
@@ -8,15 +8,23 @@
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
+ import sys
11
13
  from typing import Optional
12
14
 
13
- from datatailr import dt__User, mock_cli_tool
15
+ from datatailr.wrapper import dt__User, mock_cli_tool
16
+
17
+ # Datatailr User API Client
18
+ __client__ = dt__User()
14
19
 
15
20
 
16
21
  class User:
17
- """Representing a Datatailr User
22
+ """
23
+ Representing a Datatailr User.
24
+
18
25
  This class provides methods to interact with the Datatailr User API.
19
26
  It allows you to create, update, delete, and manage users within the Datatailr platform.
27
+
20
28
  Attributes:
21
29
  first_name (str): The first name of the user.
22
30
  last_name (str): The last name of the user.
@@ -25,6 +33,7 @@ class User:
25
33
  user_id (int): The unique identifier for the user.
26
34
  primary_group_id (int): The primary group of the user.
27
35
  is_system_user (bool): Indicates if the user is a system user.
36
+
28
37
  Static Methods:
29
38
  signed_user() -> Optional['User']:
30
39
  Retrieve the currently signed-in user, if available.
@@ -38,14 +47,12 @@ class User:
38
47
  List all users available in the Datatailr platform.
39
48
  remove(name: str) -> None:
40
49
  Remove a user by their username.
50
+
41
51
  Instance Methods:
42
52
  verify() -> None:
43
53
  Refresh the user information from the Datatailr API.
44
54
  """
45
55
 
46
- # Datatailr User API Client
47
- __client__ = dt__User()
48
-
49
56
  def __init__(self, name):
50
57
  self.__name = name
51
58
  self.__first_name = None
@@ -86,9 +93,11 @@ class User:
86
93
  def __refresh__(self):
87
94
  if not self.name:
88
95
  raise ValueError("Name is not set. Cannot refresh user.")
89
- if isinstance(User.__client__, mock_cli_tool):
96
+ if isinstance(__client__, mock_cli_tool) or any(
97
+ "unit" in arg for arg in sys.argv
98
+ ):
90
99
  return
91
- user = self.__client__.get(self.name)
100
+ user = __client__.get(self.name)
92
101
  if user:
93
102
  self.__name = user["name"]
94
103
  self.__first_name = user["first_name"]
@@ -135,22 +144,26 @@ class User:
135
144
  return self.__is_system_user
136
145
 
137
146
  @staticmethod
138
- def get(name: str) -> Optional["User"]:
147
+ def get(name: str) -> User:
139
148
  return User(name)
140
149
 
141
150
  @staticmethod
142
- def signed_user() -> "User":
143
- if isinstance(User.__client__, mock_cli_tool):
144
- user = User(name="mock_user")
151
+ def signed_user() -> User:
152
+ if isinstance(__client__, mock_cli_tool) or any(
153
+ "unit" in arg for arg in sys.argv
154
+ ):
155
+ user = User(name="test_user")
145
156
  user.__expiry__ = "mock_expiry"
146
157
  user.__signature__ = "mock_signature"
147
158
  return user
148
- user_signature_and_expiry = User.__client__.signed_user()
159
+
160
+ user_signature_and_expiry = __client__.signed_user()
149
161
  if user_signature_and_expiry:
150
162
  user = User(name=user_signature_and_expiry["name"])
151
163
  user.__expiry__ = user_signature_and_expiry["expiry"]
152
164
  user.__signature__ = user_signature_and_expiry["signature"]
153
165
  return user
166
+
154
167
  raise PermissionError(
155
168
  "No signed user found. Please ensure you are signed in to Datatailr."
156
169
  )
@@ -179,7 +192,7 @@ class User:
179
192
  system=is_system_user,
180
193
  )
181
194
  else:
182
- User.__client__.add(
195
+ __client__.add(
183
196
  name,
184
197
  first_name=first_name,
185
198
  last_name=last_name,
@@ -192,17 +205,17 @@ class User:
192
205
 
193
206
  @staticmethod
194
207
  def exists(name: str) -> bool:
195
- return User.__client__.exists(name)
208
+ return __client__.exists(name)
196
209
 
197
210
  @staticmethod
198
211
  def ls() -> list:
199
- users = User.__client__.ls()
212
+ users = __client__.ls()
200
213
  return [User.get(user["name"]) for user in users]
201
214
 
202
215
  @staticmethod
203
216
  def remove(name: str) -> None:
204
- User.__client__.rm(name)
217
+ __client__.rm(name)
205
218
  return None
206
219
 
207
220
  def verify(self) -> None:
208
- return self.__client__.verify(self.name, self.__expiry__, self.__signature__)
221
+ return __client__.verify(self.name, self.__expiry__, self.__signature__)
datatailr/utils.py CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
  import shutil
12
12
  from enum import Enum
13
+ import subprocess
14
+ from typing import Tuple
13
15
 
14
16
 
15
17
  class Environment(Enum):
@@ -33,3 +35,21 @@ def is_dt_installed():
33
35
  Check if DataTailr is installed by looking for the 'dt' command in the system PATH.
34
36
  """
35
37
  return shutil.which("dt") is not None
38
+
39
+
40
+ def run_shell_command(command: str) -> Tuple[str, int]:
41
+ """
42
+ Run a shell command.
43
+
44
+ This function executes a shell command and returns the output.
45
+
46
+ Args:
47
+ command (str): The shell command to execute.
48
+
49
+ Returns:
50
+ str: The output of the executed command.
51
+ """
52
+ result = subprocess.run(command, shell=True, capture_output=True, text=True)
53
+ if result.returncode != 0:
54
+ raise RuntimeError(f"Command '{command}' failed with error: {result.stderr}")
55
+ return result.stdout.strip(), result.returncode
datatailr/wrapper.py CHANGED
@@ -194,12 +194,6 @@ dt__Blob = globals().get("dt__Blob", mock_cli_tool)
194
194
  dt__Dns = globals().get("dt__Dns", mock_cli_tool)
195
195
  dt__System = globals().get("dt__System", mock_cli_tool)
196
196
  dt__Sms = globals().get("dt__Sms", mock_cli_tool)
197
- dt__Group = globals().get("dt__Group", mock_cli_tool)
198
- dt__Job = globals().get("dt__Job", mock_cli_tool)
199
- dt__Blob = globals().get("dt__Blob", mock_cli_tool)
200
- dt__Dns = globals().get("dt__Dns", mock_cli_tool)
201
- dt__System = globals().get("dt__System", mock_cli_tool)
202
- dt__Sms = globals().get("dt__Sms", mock_cli_tool)
203
197
  dt__Email = globals().get("dt__Email", mock_cli_tool)
204
198
  dt__Kv = globals().get("dt__Kv", mock_cli_tool)
205
199
  dt__Log = globals().get("dt__Log", mock_cli_tool)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datatailr
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: Ready-to-Use Platform That Drives Business Insights
5
5
  Author-email: Datatailr <info@datatailr.com>
6
6
  License-Expression: MIT
@@ -26,15 +26,27 @@ Requires-Dist: mypy; extra == "dev"
26
26
  Requires-Dist: types-setuptools; extra == "dev"
27
27
  Requires-Dist: toml; extra == "dev"
28
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"
29
36
  Dynamic: license-file
30
37
 
31
- [![Datatailr Logo](https://framerusercontent.com/images/6CmFcG0o2ryoa5cMuDsvwESVWA.svg)](https://www.datatailr.com/)
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
+ ---
32
45
 
33
- ___
34
46
  **Datatailr empowers your team to streamline analytics and data workflows
35
47
  from idea to production without infrastructure hurdles.**
36
48
 
37
- ## What is Datatailr?
49
+ # What is Datatailr?
38
50
 
39
51
  Datatailr is a platform that simplifies the process of building and deploying data applications.
40
52
 
@@ -69,7 +81,28 @@ print(datatailr.__provider__)
69
81
 
70
82
 
71
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.scheduler import batch, Batch
88
+
89
+ @batch()
90
+ def func_no_args() -> str:
91
+ return "no_args"
92
+
93
+
94
+ @batch()
95
+ def func_with_args(a: int, b: float) -> str:
96
+ return f"args: {a}, {b}"
97
+
98
+ with Batch(name="MY test DAG", local_run=True) as dag:
99
+ for n in range(2):
100
+ res1 = func_no_args().alias(f"func_{n}")
101
+ res2 = func_with_args(1, res1).alias(f"func_with_args_{n}")
102
+ ```
72
103
 
104
+ Running this code will create a graph of jobs and execute it.
105
+ Each node on the graph represents a job, which in turn is a call to a function decorated with `@batch()`.
73
106
 
74
107
  ___
75
108
  Visit [our website](https://www.datatailr.com/) for more!
@@ -0,0 +1,30 @@
1
+ datatailr/__init__.py,sha256=QTTG8X76BnlQwVx5N4ZQtSbLkgFipZ9NJGAbvtfuk_g,1051
2
+ datatailr/acl.py,sha256=tlDy6VlHinSy5W1FbVxcNQNi7FliWUXy3ssIbzaPp28,4157
3
+ datatailr/blob.py,sha256=xkXT6RZcMww4YfLVjOyqvvPxWc-Ku6fTJ_PeCXyBys4,3159
4
+ datatailr/dt_json.py,sha256=3xmTqDBk68oPl2UW8UVOYPaBw4lAsVg6nDLwcen5nuo,2252
5
+ datatailr/errors.py,sha256=p_e4ao3sFEfz1g4LvEDqw6bVzHJPJSINLjJ8H6_PqOo,751
6
+ datatailr/group.py,sha256=34unhas6jQH_KgQSz7N42AIT-4wAHtS9T8x-_W7AkA8,4444
7
+ datatailr/logging.py,sha256=IkucGsHfkxaiy8Ul4Qy6U3fHbqCq3mChTDoaBNovYeA,3403
8
+ datatailr/user.py,sha256=uIRMDdR_vey2r0d7aVEoq5WHb6tKLP8jBtEPc2n-xBY,7046
9
+ datatailr/utils.py,sha256=mqnnERMyHNAuAgFY4Ry4O4yW0ZjCRtJbjfI5fXVqt2s,1524
10
+ datatailr/version.py,sha256=N9K8ZxlwFFSz8XSgbgaTWZY4k2J0JKfj698nZ_O2pIU,536
11
+ datatailr/wrapper.py,sha256=K9ZD76cWey_ikA6C5sKejwRaYBDln4QMg-RcoRGiuFc,7991
12
+ datatailr/build/__init__.py,sha256=_dA7b4L6wsaAFaSxUoYSJ1oaRqDHDMR20kqoCocSOss,487
13
+ datatailr/build/image.py,sha256=xeYKPR6usg0pqJNpbhsYI8t_BB2iWxhY0KBNTWqpb_Q,4939
14
+ datatailr/sbin/datatailr_run.py,sha256=3WuvzdRrRFA0nWX9v-nShwoqjOQSnvzgZRvRvWdKJPI,5756
15
+ datatailr/sbin/datatailr_run_app.py,sha256=67Y3RQPCZ2N9LIErEdXOsnYQ_4UzTmQygjyIfMhEkyk,891
16
+ datatailr/sbin/datatailr_run_batch.py,sha256=UWnp96j_G66R_Cape7Bb-rbK6UBLF7Y5_mTlWyGJAVQ,1818
17
+ datatailr/scheduler/__init__.py,sha256=qydHYVtEP6SUWd2CQ6FRdTdRWNz3SbYPJy4FK_wOvMk,1772
18
+ datatailr/scheduler/arguments_cache.py,sha256=CydYR9o2pqfa4KsPTA1mJSBN-0YF47Q6AmODm4zAJQ4,6254
19
+ datatailr/scheduler/base.py,sha256=OkoMxTjSzpFIFikWRctN9kuZM85oJDbNET8xKe8YUQY,12558
20
+ datatailr/scheduler/batch.py,sha256=CK57jS6MvFrSj14q9ZTrD15akoBdAeTJ130MFb_aIN4,16449
21
+ datatailr/scheduler/batch_decorator.py,sha256=LqL1bsupWLn-YEQUvFJYae7R3ogrL5-VodyiiScrkRw,5806
22
+ datatailr/scheduler/constants.py,sha256=5WWTsfwZ_BA8gVDOTa2AQX9DJ0NzfaWgtY3vrODS2-8,606
23
+ datatailr/scheduler/schedule.py,sha256=vzXaBBKMVJeCGD0VxsRPeW80sYReJ83XxWzDHVgLibY,3734
24
+ datatailr/scheduler/utils.py,sha256=up6oR2iwe6G52LkvgfO394xchXgCYNjOMGRQW3e8PQk,1082
25
+ datatailr-0.1.8.dist-info/licenses/LICENSE,sha256=ikKP4_O-UD_b8FuNdKmbzTb6odd0JX085ZW_FAPN3VI,1066
26
+ datatailr-0.1.8.dist-info/METADATA,sha256=rviYJtuu-teMbR_toxDPyC3ANi5sGzWeFFxH1PhijSM,3608
27
+ datatailr-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
28
+ datatailr-0.1.8.dist-info/entry_points.txt,sha256=VVBtNTDhrPMkcqrU3XjTHrfEdPQXwbJW9kgH1C-rT7U,186
29
+ datatailr-0.1.8.dist-info/top_level.txt,sha256=75gntW0X_SKpqxLL6hAPipvpk28GAhJBvoyqN_HohWU,10
30
+ datatailr-0.1.8.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ datatailr_run = datatailr.sbin.datatailr_run:main
3
+ datatailr_run_app = datatailr.sbin.datatailr_run_app:run
4
+ datatailr_run_batch = datatailr.sbin.datatailr_run_batch:run
@@ -0,0 +1 @@
1
+ datatailr
@@ -1,29 +0,0 @@
1
- datatailr/__init__.py,sha256=god5oEAyJEGbEsxGZOwD6llaBkDNzKjCl8j2tOkiGgQ,1567
2
- datatailr/acl.py,sha256=gLuzw6FLFYLVoyXOS_oHMfd5uGKKzlDqR1WBdN_AGwQ,2862
3
- datatailr/blob.py,sha256=VImsbKBaYP6oG2Wiy4oPr6zxtUibEHpfI8p8nE1wj14,3195
4
- datatailr/dt_json.py,sha256=oos6hwC4UxT4TEbbXNSozQGhwnc_bfpo-Y2rj24ks9A,1422
5
- datatailr/errors.py,sha256=0CHvBOlzvDWoePk_preMy2qKlsztKCuQNdaQDbhNyaU,204
6
- datatailr/group.py,sha256=-DvNWBnzJ0H7RlJHWOyRiF2jbhjAsSpnJKasV1tkhfI,4481
7
- datatailr/logging.py,sha256=b3Uaumdo1ZZOaTnD-7iH1rlieWsllQSijNn9rX4svuo,3053
8
- datatailr/user.py,sha256=6oXSsH75iDI8RUM_HbTxgT6EH-2TBdheI5gnkTep-MU,6919
9
- datatailr/utils.py,sha256=eHXOc7VwIUR8ryn5jBmw5QI00ARERJwXV5oICdVRnmQ,937
10
- datatailr/version.py,sha256=N9K8ZxlwFFSz8XSgbgaTWZY4k2J0JKfj698nZ_O2pIU,536
11
- datatailr/wrapper.py,sha256=rcNqdATGsiLeyIz5bnKPIHgew5_0Z6NqJAehCjYw_AM,8303
12
- datatailr/build/__init__.py,sha256=_dA7b4L6wsaAFaSxUoYSJ1oaRqDHDMR20kqoCocSOss,487
13
- datatailr/build/image.py,sha256=P2MiGxpzuZ6hOm9JubkLoOq-RdzKYnXbKJHiryIbJeA,3103
14
- datatailr/sbin/run_job.py,sha256=B3H3UI3zpll7zVm7lZLsfPtnRlA6jjk8s_D_w89pvC4,2175
15
- datatailr/scheduler/__init__.py,sha256=YtCnv9vuX-EPGr3WBXvXJIlLsZ94mW1dBzI6h7Yjcu0,1009
16
- datatailr/scheduler/arguments_cache.py,sha256=8JKumnGvv2q2lXqbndaCkGgBoUtlg9iJ2FAs_daAHTs,5203
17
- datatailr/scheduler/base.py,sha256=IRduJjhng4Uuv3Y9vDqUNTbs636AgH2ZISWRbIP6LqQ,7826
18
- datatailr/scheduler/batch.py,sha256=yyXvYTFpPxJQsnYABWWD6ggztfMCw6GSz-TCK1ap2Jw,11182
19
- datatailr/scheduler/batch_decorator.py,sha256=BUiYupqtmSSXn0OzdFrD-gWazeJ99VqOgJkXTMa-LtE,4721
20
- datatailr/scheduler/constants.py,sha256=ISG5uMnVPbGbjaaulU0xdmSggnd-DMr9ed0WTAZSUmU,604
21
- datatailr/scheduler/utils.py,sha256=YHtAc5sCwfgiClr5G6R3hfAjdlrFdnNW2l-3XwPZLXM,1070
22
- datatailr-0.1.6.dist-info/licenses/LICENSE,sha256=ikKP4_O-UD_b8FuNdKmbzTb6odd0JX085ZW_FAPN3VI,1066
23
- test_module/__init__.py,sha256=OF9XaL3RKdbWD5Ug4L-ufLqbykSt_rTK6gqZr4uBJ8g,576
24
- test_module/test_submodule.py,sha256=O07fFbzJEy5rf1vdlYzPvs8v0IxHFg-CaYMqaHkskbc,1294
25
- datatailr-0.1.6.dist-info/METADATA,sha256=eGduuqdtOUocmi1XvIHG2gBLCXFTS7WzEGcktb5taxk,2510
26
- datatailr-0.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- datatailr-0.1.6.dist-info/entry_points.txt,sha256=4lNE9VXvztJdIQsODI308v9FRzkVgmMu-VKGEceNxJs,59
28
- datatailr-0.1.6.dist-info/top_level.txt,sha256=UZOKaWS1kZGGwV7hP476-EcSUJBNspxVSSp9WqtORzk,22
29
- datatailr-0.1.6.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- run_dt_job = datatailr.sbin.run_job:main
@@ -1,2 +0,0 @@
1
- datatailr
2
- test_module
test_module/__init__.py DELETED
@@ -1,17 +0,0 @@
1
- # *************************************************************************
2
- #
3
- # Copyright (c) 2025 - Datatailr Inc.
4
- # All Rights Reserved.
5
- #
6
- # This file is part of Datatailr and subject to the terms and conditions
7
- # defined in 'LICENSE.txt'. Unauthorized copying and/or distribution
8
- # of this file, in parts or full, via any medium is strictly prohibited.
9
- # *************************************************************************
10
-
11
- from .test_submodule import foo
12
- from .test_submodule import test_function as test_function
13
-
14
- __all__ = [
15
- "test_function",
16
- "foo",
17
- ]
@@ -1,38 +0,0 @@
1
- # *************************************************************************
2
- #
3
- # Copyright (c) 2025 - Datatailr Inc.
4
- # All Rights Reserved.
5
- #
6
- # This file is part of Datatailr and subject to the terms and conditions
7
- # defined in 'LICENSE.txt'. Unauthorized copying and/or distribution
8
- # of this file, in parts or full, via any medium is strictly prohibited.
9
- # *************************************************************************
10
-
11
- from datatailr.logging import DatatailrLogger
12
- from datatailr.scheduler import batch
13
-
14
- logger = DatatailrLogger(__name__).get_logger()
15
-
16
-
17
- @batch()
18
- def foo():
19
- logger.info(f"Running foo from {__name__}")
20
- return "Hello from foo in test_submodule"
21
-
22
-
23
- @batch()
24
- def test_function(a, b, rundate=None):
25
- """Test function for the submodule."""
26
- logger.info(f"Running test_function from test_submodule, {__name__}")
27
- logger.info(f"Arguments: a={a}, b={b}, rundate={rundate}")
28
-
29
- return f"args: ({a}, {b}, {rundate}), kwargs: {{}}"
30
-
31
-
32
- @batch()
33
- def another_test_function(x, y, z=None, rundate=None):
34
- """Another test function for the submodule."""
35
- logger.info(f"Running another_test_function from test_submodule, {__name__}")
36
- logger.info(f"Arguments: x={x}, y={y}, z={z}, rundate={rundate}")
37
-
38
- return f"args: ({x}, {y}, {z}), kwargs: {{}}"