datatailr 0.1.25__py3-none-any.whl → 0.1.27__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/group.py CHANGED
@@ -103,8 +103,8 @@ class Group:
103
103
 
104
104
  @staticmethod
105
105
  def add(name: str) -> Optional["Group"]:
106
- __client__.add(name)
107
- return Group.get(name)
106
+ new_group = __client__.add(name, json_enrichened=True)
107
+ return Group(new_group["name"]) if new_group else None
108
108
 
109
109
  @staticmethod
110
110
  def ls() -> list:
@@ -32,6 +32,7 @@
32
32
  # DATATAILR_JOB_ID - the unique identifier for the job.
33
33
 
34
34
 
35
+ import subprocess
35
36
  import os
36
37
  import sys
37
38
  from typing import Tuple
@@ -80,18 +81,29 @@ def create_user_and_group() -> Tuple[str, str]:
80
81
  return user, group
81
82
 
82
83
 
83
- def run_command_as_user(command: str, user: str, env_vars: dict):
84
+ def run_command_as_user(command: str | list, user: str, env_vars: dict):
84
85
  """
85
86
  Run a command as a specific user with the given environment variables.
86
87
  """
88
+ if isinstance(command, str):
89
+ command = command.split(" ")
87
90
  env_vars.update({"PATH": get_env_var("PATH")})
88
91
  env_vars.update({"PYTHONPATH": get_env_var("PYTHONPATH", "")})
89
- env_vars_str = " ".join(f"{key}='{value}'" for key, value in env_vars.items())
90
- full_command = f"sudo -u {user} {env_vars_str} {command}"
91
- logger.debug(f"Running command: {full_command}")
92
- status = os.system(full_command)
93
- if status != 0:
94
- logger.error(f"Command failed with status {status / 256:g}")
92
+ full_command = ["sudo", "-u", user, "bash", "-c", *command]
93
+
94
+ try:
95
+ result = subprocess.run(
96
+ full_command,
97
+ env=env_vars,
98
+ check=True, # raises if returncode != 0
99
+ capture_output=True,
100
+ text=True,
101
+ )
102
+ logger.info(f"stdout: {result.stdout}")
103
+ logger.debug(f"stderr: {result.stderr}")
104
+ except subprocess.CalledProcessError as e:
105
+ logger.error(f"Command failed with exit code {e.returncode}")
106
+ logger.error(f"stderr: {e.stderr}")
95
107
  sys.exit(1)
96
108
 
97
109
 
@@ -138,7 +150,9 @@ def main():
138
150
  } | env
139
151
  run_command_as_user("datatailr_run_excel", user, env)
140
152
  elif job_type == "IDE":
141
- pass
153
+ run_command_as_user("code server", user, env)
154
+ elif job_type == "jupyter":
155
+ run_command_as_user("jupyter lab", user, env)
142
156
  else:
143
157
  raise ValueError(f"Unknown job type: {job_type}")
144
158
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datatailr
3
- Version: 0.1.25
3
+ Version: 0.1.27
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 @@ datatailr/blob.py,sha256=9lKZKm4eRKVE4_t2zy3hh6Z_Ov4iaTA3-tJFjnQKezg,3313
4
4
  datatailr/dt_json.py,sha256=3xmTqDBk68oPl2UW8UVOYPaBw4lAsVg6nDLwcen5nuo,2252
5
5
  datatailr/errors.py,sha256=p_e4ao3sFEfz1g4LvEDqw6bVzHJPJSINLjJ8H6_PqOo,751
6
6
  datatailr/excel.py,sha256=7_13VFHrjHlIAEeTaGQIlq4ycJvzRo-TvkP_KRBELGs,425
7
- datatailr/group.py,sha256=ExsrkqUooAfFLWKvnkp1ZxisSJD1yCp9TKqoCXDCwhs,4360
7
+ datatailr/group.py,sha256=AC0nCA44eEWZCJCq2klPqkFg_995mS3C_wu5uSFFLtU,4426
8
8
  datatailr/logging.py,sha256=4Rsx3wf2tAr1334E2goBjhC877RwbUNaFgBlh902vU4,3270
9
9
  datatailr/user.py,sha256=tjIMbQ-tb2yFhgLBl_eTb47kKiy-RoM3KtYS3zmJiwc,6736
10
10
  datatailr/utils.py,sha256=mqnnERMyHNAuAgFY4Ry4O4yW0ZjCRtJbjfI5fXVqt2s,1524
@@ -12,7 +12,7 @@ datatailr/version.py,sha256=N9K8ZxlwFFSz8XSgbgaTWZY4k2J0JKfj698nZ_O2pIU,536
12
12
  datatailr/wrapper.py,sha256=K9ZD76cWey_ikA6C5sKejwRaYBDln4QMg-RcoRGiuFc,7991
13
13
  datatailr/build/__init__.py,sha256=_dA7b4L6wsaAFaSxUoYSJ1oaRqDHDMR20kqoCocSOss,487
14
14
  datatailr/build/image.py,sha256=YC8ML-l-sj6TcIBY-DCx_vaeI_7SmL9fPFhHnuxzRh0,5509
15
- datatailr/sbin/datatailr_run.py,sha256=uuhzINoBm2O59UcSe7H1iNkPwIlGh6nqor4EwNTKNwg,5952
15
+ datatailr/sbin/datatailr_run.py,sha256=A8H2VigdKUxXQuxfy2Y09KOj5iY0nggZqlS8E9hThYQ,6386
16
16
  datatailr/sbin/datatailr_run_app.py,sha256=AOkutzv4DeKfWZs-ZBciAMKnK4A05SfkVf1ZJnSSFwA,1231
17
17
  datatailr/sbin/datatailr_run_batch.py,sha256=UWnp96j_G66R_Cape7Bb-rbK6UBLF7Y5_mTlWyGJAVQ,1818
18
18
  datatailr/sbin/datatailr_run_excel.py,sha256=Gr_QZgqJrwgRVD9_o4v-2tbvU-QMvNHL7xUvFGhftFc,1163
@@ -25,9 +25,9 @@ datatailr/scheduler/batch_decorator.py,sha256=LqL1bsupWLn-YEQUvFJYae7R3ogrL5-Vod
25
25
  datatailr/scheduler/constants.py,sha256=5WWTsfwZ_BA8gVDOTa2AQX9DJ0NzfaWgtY3vrODS2-8,606
26
26
  datatailr/scheduler/schedule.py,sha256=0XJJen2nL1xplRs0Xbjwgq3T-0bFCOrJzkSALdio998,3741
27
27
  datatailr/scheduler/utils.py,sha256=up6oR2iwe6G52LkvgfO394xchXgCYNjOMGRQW3e8PQk,1082
28
- datatailr-0.1.25.dist-info/licenses/LICENSE,sha256=ikKP4_O-UD_b8FuNdKmbzTb6odd0JX085ZW_FAPN3VI,1066
29
- datatailr-0.1.25.dist-info/METADATA,sha256=peUpI8-_NsE4zq2Fv63aUMtgwzqhRhpSfSnRLy-bU-s,5146
30
- datatailr-0.1.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- datatailr-0.1.25.dist-info/entry_points.txt,sha256=YqXfk2At-olW4PUSRkqvy_O3Mbv7uTKCCPuAAiz3Qbg,312
32
- datatailr-0.1.25.dist-info/top_level.txt,sha256=75gntW0X_SKpqxLL6hAPipvpk28GAhJBvoyqN_HohWU,10
33
- datatailr-0.1.25.dist-info/RECORD,,
28
+ datatailr-0.1.27.dist-info/licenses/LICENSE,sha256=ikKP4_O-UD_b8FuNdKmbzTb6odd0JX085ZW_FAPN3VI,1066
29
+ datatailr-0.1.27.dist-info/METADATA,sha256=0U7ze0UBwQ6n8KlnE97KKQTlTHjhPrGByhtUupcjtXE,5146
30
+ datatailr-0.1.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
+ datatailr-0.1.27.dist-info/entry_points.txt,sha256=YqXfk2At-olW4PUSRkqvy_O3Mbv7uTKCCPuAAiz3Qbg,312
32
+ datatailr-0.1.27.dist-info/top_level.txt,sha256=75gntW0X_SKpqxLL6hAPipvpk28GAhJBvoyqN_HohWU,10
33
+ datatailr-0.1.27.dist-info/RECORD,,