dataflow-core 2.0.5__py3-none-any.whl → 2.0.7__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 dataflow-core might be problematic. Click here for more details.

@@ -65,7 +65,23 @@ class DataflowHubAuthenticator(Authenticator):
65
65
  self.db.refresh(db_item)
66
66
 
67
67
  expires = datetime.now(timezone.utc) + timedelta(days=365)
68
- handler.set_cookie("dataflow_session", session_id, expires=expires)
68
+ host = handler.request.host
69
+ parts = host.split('.')
70
+ if len(parts) >= 2:
71
+ domain = '.'.join(parts[-2:])
72
+ else:
73
+ domain = host
74
+ base_domain = f".{domain}"
75
+ handler.set_cookie(
76
+ "dataflow_session",
77
+ session_id,
78
+ domain=base_domain,
79
+ path="/",
80
+ expires=expires,
81
+ secure=True,
82
+ httponly=True,
83
+ samesite="None"
84
+ )
69
85
  user_dict = {"name": username, "session_id": session_id}
70
86
  return user_dict
71
87
 
dataflow/dataflow.py CHANGED
@@ -2,21 +2,21 @@ import os, requests
2
2
  from .models.database import DatabaseManager
3
3
  from sqlalchemy.inspection import inspect
4
4
  from .utils.aws_secrets_manager import SecretsManagerClient
5
- import json
5
+ import json, asyncio, pkg_resources
6
6
  from authenticator.package.configuration import ConfigurationManager
7
7
 
8
8
 
9
9
  class Dataflow:
10
10
  def __init__(self):
11
- self.dataflow_config = ConfigurationManager('/dataflow/app/auth_config/dataflow_auth.cfg')
12
- self.auth_api = self.dataflow_config.get_config_value('auth', 'ui_auth_api')
13
11
  self.secrets_manager = SecretsManagerClient('us-east-1')
14
12
 
15
13
  def auth(self, session_id: str):
16
14
  """Retrieve user information from the auth API."""
17
15
  try:
16
+ dataflow_config = ConfigurationManager('/dataflow/app/auth_config/dataflow_auth.cfg')
17
+ auth_api = dataflow_config.get_config_value('auth', 'ui_auth_api')
18
18
  response = requests.get(
19
- self.auth_api,
19
+ auth_api,
20
20
  cookies={"dataflow_session": session_id, "jupyterhub-hub-login": ""}
21
21
  )
22
22
 
@@ -86,3 +86,42 @@ class Dataflow:
86
86
 
87
87
  except Exception as e:
88
88
  return None
89
+
90
+ async def create_env(self, env_name, py_version, py_requirements, status, env_version=None):
91
+ """
92
+ Creates a conda environment at the specified path and installs libraries in one command.
93
+ """
94
+ config = ConfigurationManager('/dataflow/app/config/dataflow.cfg')
95
+ status = status.lower()
96
+ if status == "published":
97
+ env_base_path = config.get_config_value('paths', 'published_env_path')
98
+ conda_env_path = os.path.join(env_base_path, env_name)
99
+ else:
100
+ env_base_path = config.get_config_value('paths', 'drafts_env_path')
101
+ conda_env_path = os.path.join(env_base_path, env_name, f"{env_name}_v{env_version}")
102
+ try:
103
+ if not os.path.exists(conda_env_path):
104
+ os.makedirs(conda_env_path, exist_ok=True)
105
+
106
+ py_requirements = ",".join(py_requirements)
107
+
108
+ script_path = pkg_resources.resource_filename('dataflow', 'scripts/create_environment.sh')
109
+
110
+ # Make the script executable
111
+ os.chmod(script_path, 0o755)
112
+
113
+ # Prepare command with arguments
114
+ command = ["bash", script_path, py_requirements, conda_env_path, py_version]
115
+
116
+ process = await asyncio.create_subprocess_exec(
117
+ *command,
118
+ stdout=asyncio.subprocess.PIPE,
119
+ stderr=asyncio.subprocess.PIPE
120
+ )
121
+
122
+ return process
123
+ except OSError as e:
124
+ print(f"OS error while creating {conda_env_path}: {e}")
125
+ except Exception as e:
126
+ print(f"Unexpected error while creating {conda_env_path}: {e}")
127
+ return {"error": str(e)}
@@ -0,0 +1,34 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ IFS=',' read -r -a libraries <<< $1
5
+ conda_env_path=$2
6
+ py_version=$3
7
+
8
+ # Use an isolated conda package cache to avoid concurrency issues
9
+ export CONDA_PKGS_DIRS=$(mktemp -d)
10
+ # to delete conda package cache after script finishes
11
+ trap 'rm -rf "$CONDA_PKGS_DIRS"' EXIT
12
+
13
+ # 1. Creating conda environment
14
+ conda create --prefix ${conda_env_path} --yes python=${py_version}
15
+ ${conda_env_path}/bin/pip install --root-user-action ignore ${libraries[@]}
16
+
17
+ # 3. Install Dataflow Airflow to a separate path in environment
18
+ ${conda_env_path}/bin/pip install \
19
+ --force-reinstall --root-user-action ignore \
20
+ --no-warn-conflicts dataflow-airflow==2.10.5 \
21
+ --target ${conda_env_path}/bin/airflow-libraries/ \
22
+ --constraint https://raw.githubusercontent.com//apache/airflow/constraints-2.10.5/constraints-${py_version}.txt || true
23
+
24
+ files=(
25
+ ${conda_env_path}/lib/python${py_version}/site-packages/dbt/config/profile.py
26
+ ${conda_env_path}/lib/python${py_version}/site-packages/dbt/task/debug.py
27
+ )
28
+ for file in ${files[@]}
29
+ do
30
+ awk '{gsub("from dbt.clients.yaml_helper import load_yaml_text", "from dbt.dataflow_config.secrets_manager import load_yaml_text"); print}' $file > temp
31
+ mv temp $file
32
+ done
33
+
34
+ echo "Environment Creation Successful"
@@ -1,18 +1,14 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: dataflow-core
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: Dataflow core package
5
- Home-page: UNKNOWN
6
5
  Author: Dataflow
7
- Author-email: UNKNOWN
8
- License: UNKNOWN
9
- Platform: UNKNOWN
6
+ Author-email:
10
7
  Requires-Dist: sqlalchemy
11
8
  Requires-Dist: boto3
12
9
  Requires-Dist: psycopg2-binary
13
10
  Requires-Dist: pymysql
14
11
  Requires-Dist: requests
15
-
16
- UNKNOWN
17
-
18
-
12
+ Dynamic: author
13
+ Dynamic: requires-dist
14
+ Dynamic: summary
@@ -1,6 +1,6 @@
1
1
  authenticator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  authenticator/dataflowairflowauthenticator.py,sha256=PcGlL2cq5EA9RdtClyrOupvNXxk6h54UPQcQ-g4VQtA,3117
3
- authenticator/dataflowhubauthenticator.py,sha256=UgjZiXSP-hlbciyJVb-QIgUjS3_EgX0WIvbhD563rVw,2918
3
+ authenticator/dataflowhubauthenticator.py,sha256=m7ef84WfAjQ0IM8bg-1JhPs75rMNwKq3B0ZB5XF-07w,3403
4
4
  authenticator/dataflowsupersetauthenticator.py,sha256=M2pNpIdmWwzJVuMQ6trXLWQT4HpcYT84bC93uOSm0fQ,1772
5
5
  authenticator/package/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  authenticator/package/configuration.py,sha256=7To6XwH1eESiYp39eqPcswXWwrdBUdPF6xN6WnazOF0,663
@@ -10,15 +10,14 @@ authenticator/package/models/session.py,sha256=j6PhbrTMJxEkeDT4Vf5SqGtM_LI_vZy9O
10
10
  authenticator/package/models/user.py,sha256=IYogp_vt0yDBG5i936uNPjgTis77VYPzITn9XpQUIyw,788
11
11
  dataflow/__init__.py,sha256=WTRg8HMpMWSgxYJ9ZGVldx4k07fAbta3mBmZ1hG9mWE,30
12
12
  dataflow/configuration.py,sha256=7To6XwH1eESiYp39eqPcswXWwrdBUdPF6xN6WnazOF0,663
13
- dataflow/dataflow.py,sha256=8jLshxmxVtBTF6LYIGD9RJyB1mujo0tNr8vjHE04JNE,3418
13
+ dataflow/dataflow.py,sha256=viEKxu1bVFtenbPx8etCb7Gf-Hbwv0KvkE7occVbX8I,5136
14
14
  dataflow/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  dataflow/models/database.py,sha256=y09pqnglsBBtDZlyhvqDAlpUSFovwAzBAi6jOYl_XNk,896
16
- dataflow/models/session.py,sha256=C9crPh6ZDFuL27hZ_zhUXDZZ0ZiIDE8ZD19O_4WPw-I,488
17
- dataflow/models/user.py,sha256=IYogp_vt0yDBG5i936uNPjgTis77VYPzITn9XpQUIyw,788
16
+ dataflow/scripts/create_environment.sh,sha256=nnE2295DCflUGz11RR0k6-TulQlpoXLqEpKZ9QU5t6g,1300
18
17
  dataflow/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
18
  dataflow/utils/aws_secrets_manager.py,sha256=FqHm3YRynv580FpFsS0RfI1MSGY5aq-V7t4blpiYsS4,2588
20
- dataflow_core-2.0.5.dist-info/METADATA,sha256=L8jAsmbkSv0xT9rh2Ac2t3dHuI0kJMLhVDXcnUWYbyk,317
21
- dataflow_core-2.0.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
22
- dataflow_core-2.0.5.dist-info/entry_points.txt,sha256=lDLG2MMWlKfkqsVWFghF7sx-yEvM2xqMmHE7rMTysE4,118
23
- dataflow_core-2.0.5.dist-info/top_level.txt,sha256=SZsUOpSCK9ntUy-3Tusxzf5A2e8ebwD8vouPb1dPt_8,23
24
- dataflow_core-2.0.5.dist-info/RECORD,,
19
+ dataflow_core-2.0.7.dist-info/METADATA,sha256=em6wCVL-OURnlA9c7tHV_25vCM6fsrEVuRCOuAtIKBo,301
20
+ dataflow_core-2.0.7.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
21
+ dataflow_core-2.0.7.dist-info/entry_points.txt,sha256=ppj_EIbYrJJwCPg1kfdsZk5q1N-Ejfis1neYrnjhO8o,117
22
+ dataflow_core-2.0.7.dist-info/top_level.txt,sha256=SZsUOpSCK9ntUy-3Tusxzf5A2e8ebwD8vouPb1dPt_8,23
23
+ dataflow_core-2.0.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.45.1)
2
+ Generator: setuptools (80.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,3 +1,2 @@
1
1
  [jupyterhub.authenticators]
2
2
  dataflow_authenticator = authenticator.dataflowhubauthenticator:DataflowHubAuthenticator
3
-
@@ -1,17 +0,0 @@
1
- """models.py"""
2
- from sqlalchemy import Column, Integer, String
3
- from sqlalchemy.ext.declarative import declarative_base
4
-
5
- #instance for create declarative base
6
- Base=declarative_base()
7
-
8
- class Session_table(Base):
9
- """
10
- Table SESSIONS
11
- """
12
-
13
- __tablename__='SESSION'
14
-
15
- id = Column(Integer, primary_key=True, index=True, unique=True, nullable=False, autoincrement=True)
16
- session_id = Column(String, unique=True, nullable=False)
17
- user_id = Column(String, nullable=False)
dataflow/models/user.py DELETED
@@ -1,23 +0,0 @@
1
- """models.py"""
2
- from sqlalchemy import Column, Integer, String, LargeBinary, Enum
3
- from sqlalchemy.ext.declarative import declarative_base
4
-
5
- #instance for create declarative base
6
- Base=declarative_base()
7
-
8
- class User(Base):
9
- """
10
- Table USER
11
- """
12
-
13
- __tablename__='USER'
14
-
15
- user_id = Column(Integer, primary_key=True, index=True, autoincrement=True, nullable=False)
16
- user_name = Column(String, unique=True, nullable=False)
17
- first_name = Column(String)
18
- last_name = Column(String)
19
- email = Column(String, unique=True)
20
- role = Column(Enum('admin', 'user', name='role_field'), nullable=False)
21
- image = Column(LargeBinary)
22
- active = Column(Enum('N', 'Y', name='active_field'), nullable=False, server_default=str("N"))
23
- password = Column(String, nullable=False)