datatailr 0.1.45__tar.gz → 0.1.47__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.

Files changed (39) hide show
  1. {datatailr-0.1.45/src/datatailr.egg-info → datatailr-0.1.47}/PKG-INFO +1 -1
  2. {datatailr-0.1.45 → datatailr-0.1.47}/pyproject.toml +1 -1
  3. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/scheduler/base.py +8 -2
  4. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/scheduler/batch.py +17 -1
  5. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/utils.py +12 -0
  6. {datatailr-0.1.45 → datatailr-0.1.47/src/datatailr.egg-info}/PKG-INFO +1 -1
  7. {datatailr-0.1.45 → datatailr-0.1.47}/src/sbin/datatailr_run.py +5 -3
  8. {datatailr-0.1.45 → datatailr-0.1.47}/LICENSE +0 -0
  9. {datatailr-0.1.45 → datatailr-0.1.47}/README.md +0 -0
  10. {datatailr-0.1.45 → datatailr-0.1.47}/setup.cfg +0 -0
  11. {datatailr-0.1.45 → datatailr-0.1.47}/setup.py +0 -0
  12. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/__init__.py +0 -0
  13. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/acl.py +0 -0
  14. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/blob.py +0 -0
  15. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/build/__init__.py +0 -0
  16. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/build/image.py +0 -0
  17. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/dt_json.py +0 -0
  18. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/errors.py +0 -0
  19. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/excel.py +0 -0
  20. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/group.py +0 -0
  21. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/logging.py +0 -0
  22. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/scheduler/__init__.py +0 -0
  23. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/scheduler/arguments_cache.py +0 -0
  24. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/scheduler/batch_decorator.py +0 -0
  25. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/scheduler/constants.py +0 -0
  26. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/scheduler/schedule.py +0 -0
  27. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/scheduler/utils.py +0 -0
  28. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/user.py +0 -0
  29. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/version.py +0 -0
  30. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr/wrapper.py +0 -0
  31. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr.egg-info/SOURCES.txt +0 -0
  32. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr.egg-info/dependency_links.txt +0 -0
  33. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr.egg-info/entry_points.txt +0 -0
  34. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr.egg-info/requires.txt +0 -0
  35. {datatailr-0.1.45 → datatailr-0.1.47}/src/datatailr.egg-info/top_level.txt +0 -0
  36. {datatailr-0.1.45 → datatailr-0.1.47}/src/sbin/datatailr_run_app.py +0 -0
  37. {datatailr-0.1.45 → datatailr-0.1.47}/src/sbin/datatailr_run_batch.py +0 -0
  38. {datatailr-0.1.45 → datatailr-0.1.47}/src/sbin/datatailr_run_excel.py +0 -0
  39. {datatailr-0.1.45 → datatailr-0.1.47}/src/sbin/datatailr_run_service.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datatailr
3
- Version: 0.1.45
3
+ Version: 0.1.47
4
4
  Summary: Ready-to-Use Platform That Drives Business Insights
5
5
  Author-email: Datatailr <info@datatailr.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "datatailr"
7
- version = "0.1.45"
7
+ version = "0.1.47"
8
8
  description = "Ready-to-Use Platform That Drives Business Insights"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -18,7 +18,7 @@ import tempfile
18
18
  import uuid
19
19
  from dataclasses import dataclass
20
20
  from enum import Enum
21
- from typing import Callable, Optional, Tuple, Union
21
+ from typing import Callable, Dict, Optional, Tuple, Union
22
22
 
23
23
  from datatailr import ACL, Environment, User, is_dt_installed
24
24
  from datatailr.wrapper import dt__Job
@@ -26,7 +26,7 @@ from datatailr.scheduler.constants import DEFAULT_TASK_MEMORY, DEFAULT_TASK_CPU
26
26
  from datatailr.build.image import Image
27
27
  from datatailr.errors import BatchJobError
28
28
  from datatailr.logging import DatatailrLogger
29
- from datatailr.utils import run_shell_command
29
+ from datatailr.utils import run_shell_command, dict_to_env_vars
30
30
 
31
31
  logger = DatatailrLogger(os.path.abspath(__file__)).get_logger()
32
32
  __client__ = dt__Job()
@@ -148,6 +148,7 @@ class Job:
148
148
  python_requirements: str = "",
149
149
  build_script_pre: str = "",
150
150
  build_script_post: str = "",
151
+ env_vars: Dict[str, str | int | float | bool] = {},
151
152
  type: Optional[JobType] = JobType.UNKNOWN,
152
153
  entrypoint: Optional[EntryPoint] = None,
153
154
  update_existing: bool = False,
@@ -186,6 +187,7 @@ class Job:
186
187
  self.type = type if entrypoint is None else entrypoint.type
187
188
  self.entrypoint = entrypoint
188
189
  self.__id = str(uuid.uuid4())
190
+ self.__env_vars = env_vars
189
191
 
190
192
  @property
191
193
  def id(self) -> str:
@@ -237,8 +239,12 @@ class Job:
237
239
  "memory": self.resources.memory,
238
240
  "cpu": self.resources.cpu,
239
241
  }
242
+ if self.type == JobType.EXCEL:
243
+ if "DATATAILR_LOCAL" not in self.__env_vars:
244
+ self.__env_vars.update({"DATATAILR_LOCAL": "false"})
240
245
  if self.type != JobType.BATCH:
241
246
  job_dict["entrypoint"] = str(self.entrypoint) if self.entrypoint else None
247
+ job_dict["env"] = dict_to_env_vars(self.__env_vars)
242
248
  return job_dict
243
249
 
244
250
  def from_dict(self, job_dict: dict):
@@ -32,7 +32,7 @@ from datatailr.scheduler.base import (
32
32
  from datatailr.scheduler.constants import DEFAULT_TASK_CPU, DEFAULT_TASK_MEMORY
33
33
  from datatailr.scheduler.arguments_cache import ArgumentsCache
34
34
  from datatailr.scheduler.schedule import Schedule
35
- from datatailr.utils import is_dt_installed
35
+ from datatailr.utils import is_dt_installed, dict_to_env_vars
36
36
 
37
37
  __DAG_CONTEXT__: contextvars.ContextVar = contextvars.ContextVar("dag_context")
38
38
  __ARGUMENTS_CACHE__ = ArgumentsCache()
@@ -97,6 +97,7 @@ class BatchJob:
97
97
  dependencies: Sequence[Union[str, BatchJob]] = [],
98
98
  dag: Optional[Batch] = get_current_manager(),
99
99
  argument_mapping: Dict[str, str] = {},
100
+ env_vars: Dict[str, str | int | float | bool] = {},
100
101
  ):
101
102
  self.name = name
102
103
  self.entrypoint = entrypoint
@@ -112,6 +113,7 @@ class BatchJob:
112
113
  assert all(
113
114
  isinstance(dep, int) for dep in self.dependencies
114
115
  ), "All dependencies must be integers representing job IDs."
116
+ self.__env_vars = env_vars
115
117
  self.dag.add_job(self)
116
118
  self.argument_mapping = argument_mapping or {}
117
119
 
@@ -193,6 +195,16 @@ class BatchJob:
193
195
  def __setstate__(self, state: dict):
194
196
  self.__dict__.update(state)
195
197
 
198
+ def update_env_vars(self, env_vars: Dict[str, str | int | float | bool]) -> None:
199
+ """
200
+ Update the environment variables for the BatchJob instance.
201
+
202
+ :param env_vars: A dictionary of environment variables to update.
203
+ """
204
+ env = env_vars.copy()
205
+ env.update(self.__env_vars)
206
+ self.__env_vars = env
207
+
196
208
  def to_dict(self):
197
209
  """
198
210
  Convert the BatchJob instance to a dictionary representation.
@@ -205,6 +217,7 @@ class BatchJob:
205
217
  "memory": self.resources.memory if self.resources else DEFAULT_TASK_MEMORY,
206
218
  "cpu": self.resources.cpu if self.resources else DEFAULT_TASK_CPU,
207
219
  "depends_on": list(self.dependencies),
220
+ "env": dict_to_env_vars(self.__env_vars),
208
221
  }
209
222
 
210
223
  def to_json(self):
@@ -308,6 +321,7 @@ class Batch(Job):
308
321
  python_requirements: str = "",
309
322
  build_script_pre: str = "",
310
323
  build_script_post: str = "",
324
+ env_vars: Dict[str, str | int | float | bool] = {},
311
325
  ):
312
326
  super().__init__(
313
327
  environment=environment,
@@ -327,6 +341,7 @@ class Batch(Job):
327
341
  self.__BATCH_JOB_NAMES__: Dict[str, int] = {}
328
342
  self.__local_run = local_run
329
343
  self.__schedule = schedule
344
+ self.__env_vars = env_vars
330
345
 
331
346
  @property
332
347
  def next_job_id(self):
@@ -369,6 +384,7 @@ class Batch(Job):
369
384
  f"Function {job.entrypoint.function_name} is defined in a different module: "
370
385
  f"{package_path_to_module} != {image_path_to_module}"
371
386
  )
387
+ job.update_env_vars(self.__env_vars)
372
388
  self.__jobs.append(job)
373
389
 
374
390
  def is_job_in(self, job: BatchJob) -> bool:
@@ -53,3 +53,15 @@ def run_shell_command(command: str) -> Tuple[str, int]:
53
53
  if result.returncode != 0:
54
54
  raise RuntimeError(f"Command '{command}' failed with error: {result.stderr}")
55
55
  return result.stdout.strip(), result.returncode
56
+
57
+
58
+ def dict_to_env_vars(env_vars: dict) -> list:
59
+ """Convert a dictionary of environment variables to a list format suitable for shell commands.
60
+
61
+ Args:
62
+ env_vars (dict): A dictionary where keys are environment variable names and values are their corresponding values.
63
+
64
+ Returns:
65
+ list: A list of lists, where each inner list contains a key-value pair representing an environment variable.
66
+ """
67
+ return [[key, str(value)] for key, value in env_vars.items()]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datatailr
3
- Version: 0.1.45
3
+ Version: 0.1.47
4
4
  Summary: Ready-to-Use Platform That Drives Business Insights
5
5
  Author-email: Datatailr <info@datatailr.com>
6
6
  License-Expression: MIT
@@ -85,15 +85,15 @@ def run_command_as_user(command: str | list, user: str, env_vars: dict):
85
85
  """
86
86
  Run a command as a specific user with the given environment variables.
87
87
  """
88
- if isinstance(command, str):
89
- command = command.split(" ")
88
+ if isinstance(command, list):
89
+ command = " ".join(command)
90
90
  env_vars = {
91
91
  "PATH": get_env_var("PATH", ""),
92
92
  "PYTHONPATH": get_env_var("PYTHONPATH", ""),
93
93
  } | env_vars
94
94
 
95
95
  env_kv = [f"{k}={v}" for k, v in env_vars.items()]
96
- argv = ["sudo", "-u", user, "env", *env_kv, "bash", "-lc", *command]
96
+ argv = ["sudo", "-u", user, "env", *env_kv, "bash", "-lc", command]
97
97
 
98
98
  try:
99
99
  result = subprocess.run(
@@ -147,9 +147,11 @@ def main():
147
147
  elif job_type == "excel":
148
148
  host = get_env_var("DATATAILR_HOST", "")
149
149
  entrypoint = get_env_var("DATATAILR_ENTRYPOINT")
150
+ local = get_env_var("DATATAILR_LOCAL", False)
150
151
  env = {
151
152
  "DATATAILR_ENTRYPOINT": entrypoint,
152
153
  "DATATAILR_HOST": host,
154
+ "DATATAILR_LOCAL": local,
153
155
  } | env
154
156
  run_command_as_user("datatailr_run_excel", user, env)
155
157
  elif job_type == "ide":
File without changes
File without changes
File without changes
File without changes