dataflow-conda-plugin 0.1.3rc1__py3-none-any.whl → 0.1.4__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-conda-plugin might be problematic. Click here for more details.

@@ -1,3 +1,3 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataflow-conda-plugin
3
- Version: 0.1.3rc1
3
+ Version: 0.1.4
@@ -0,0 +1,8 @@
1
+ plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ plugin/plugin.py,sha256=83cYuYaTDyYNPY_mWgn_isJaBb8G3kuUbzZtM7Yx15Q,6209
3
+ plugin/scripts/install_dataflow_deps.sh,sha256=hp_v6h5Ikh9K4kp80-le8BNhjnP6znyQdKlw5-bC54o,1122
4
+ dataflow_conda_plugin-0.1.4.dist-info/METADATA,sha256=itEkiWPFhSW-67tRwEFsxgAUsr2OHYzBbZpCXKdYAUI,65
5
+ dataflow_conda_plugin-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ dataflow_conda_plugin-0.1.4.dist-info/entry_points.txt,sha256=Vk2GKuQjr-5WV4NDKyPsnF37p3LUoAgPYOSMHxnpac8,46
7
+ dataflow_conda_plugin-0.1.4.dist-info/top_level.txt,sha256=Io_dflkI6h0vZSGOzZxx4e76CDTSANVfu4v4tVY6zsA,7
8
+ dataflow_conda_plugin-0.1.4.dist-info/RECORD,,
plugin/plugin.py CHANGED
@@ -1,12 +1,13 @@
1
- import subprocess, sys, pkg_resources, os
1
+ import subprocess, sys, pkg_resources, os, requests
2
2
  from conda import plugins
3
3
  from conda.base.context import context
4
- from dataflow.models import LocalEnvironment
5
- from dataflow.db import get_local_db
6
- from datetime import datetime, timezone
7
4
  from dataflow.utils.logger import CustomLogger
5
+ from dataflow.configuration import ConfigurationManager
8
6
 
9
7
  logger = CustomLogger().get_logger(__name__)
8
+ dataflow_config = ConfigurationManager('/dataflow/app/auth_config/dataflow_auth.cfg')
9
+
10
+ env_api = dataflow_config.get_config_value('auth', 'env_api')
10
11
 
11
12
  def is_local_environment(target_prefix):
12
13
  """Check if the environment is a local user environment."""
@@ -16,36 +17,30 @@ def is_local_environment(target_prefix):
16
17
  target_prefix.startswith('/home/jovyan')
17
18
  )
18
19
 
19
- def save_environment_to_db(env_name: str, status: str = "Created"):
20
- """Save environment information to LocalEnvironment table."""
20
+ def save_environment(env_name: str, status: str):
21
+ """Save environment information via API."""
21
22
  try:
22
- db_generator = get_local_db()
23
- db = next(db_generator)
24
-
25
- # Check if environment already exists
26
- existing_env = db.query(LocalEnvironment).filter_by(name=env_name).first()
27
- if existing_env:
28
- # Update status if environment exists
29
- existing_env.status = status
30
- existing_env.updated_at = datetime.now(timezone.utc)
31
- db.commit()
32
- return
33
-
34
- # Create new LocalEnvironment record
35
- local_env = LocalEnvironment(
36
- name=env_name,
37
- status=status,
38
- updated_at=datetime.now(timezone.utc)
23
+ response = requests.post(
24
+ env_api,
25
+ params={
26
+ "env_name": env_name,
27
+ "status": status
28
+ },
29
+ timeout=30
39
30
  )
40
31
 
41
- db.add(local_env)
42
- db.commit()
43
-
32
+ if response.status_code in [200, 201]:
33
+ logger.info(f"Environment '{env_name}' saved successfully")
34
+ else:
35
+ logger.error(f"Error saving environment: {response.status_code} - {response.text}")
36
+ print("Error saving environment! Please try again after deleting the environment")
37
+
38
+ except requests.exceptions.RequestException as e:
39
+ logger.error(f"Network error saving environment: {str(e)}")
40
+ print("Error saving environment! Please check your connection and try again")
44
41
  except Exception as e:
42
+ logger.error(f"Unexpected error saving environment: {str(e)}")
45
43
  print("Error saving environment! Please try again after deleting the environment")
46
- logger.error(f"Error saving environment to database: {str(e)}")
47
- finally:
48
- db_generator.close()
49
44
 
50
45
  def install_deps(command: str):
51
46
  """Install dataflow dependencies."""
@@ -58,9 +53,12 @@ def install_deps(command: str):
58
53
  try:
59
54
  if (args.get('clone') is not None):
60
55
  if should_save_to_db:
61
- save_environment_to_db(env_name, "Created")
56
+ save_environment(env_name, "Success")
62
57
  return
63
58
 
59
+ if env_name and should_save_to_db:
60
+ save_environment(env_name, "Success")
61
+
64
62
  install_dataflow_deps = pkg_resources.resource_filename('plugin', 'scripts/install_dataflow_deps.sh')
65
63
  process = subprocess.Popen(
66
64
  ["bash", install_dataflow_deps, target_prefix],
@@ -78,36 +76,60 @@ def install_deps(command: str):
78
76
  if return_code != 0:
79
77
  print(f"Error in creating environment!!")
80
78
  if should_save_to_db and env_name:
81
- save_environment_to_db(env_name, "Failed")
79
+ save_environment(env_name, "Failed")
82
80
  else:
83
81
  if env_name and should_save_to_db:
84
- save_environment_to_db(env_name, "Created")
82
+ save_environment(env_name, "Success")
85
83
 
86
84
  except Exception as e:
87
85
  print(f"An unexpected error occurred: {str(e)}\nPlease delete the environment and try again.")
88
86
  logger.error(f"Error installing dependencies: {str(e)}")
89
87
  if should_save_to_db and env_name:
90
- save_environment_to_db(env_name, "Failed")
88
+ save_environment(env_name, "Failed")
89
+
90
+ def remove_environment(env_name: str):
91
+ """Remove environment information via API."""
92
+ try:
93
+ response = requests.delete(
94
+ env_api,
95
+ params={"env_name": env_name},
96
+ timeout=30
97
+ )
98
+
99
+ if response.status_code == 200:
100
+ logger.info(f"Environment '{env_name}' removed successfully")
101
+ elif response.status_code == 404:
102
+ logger.warning(f"Environment '{env_name}' not found")
103
+ else:
104
+ logger.error(f"Error removing environment: {response.status_code} - {response.text}")
105
+ print("Error removing environment! Please delete from the dataflow environment page")
106
+
107
+ except requests.exceptions.RequestException as e:
108
+ logger.error(f"Network error removing environment: {str(e)}")
109
+ print("Error removing environment! Please delete from the dataflow environment page")
110
+ except Exception as e:
111
+ logger.error(f"Unexpected error removing environment: {str(e)}")
112
+ print("Error removing environment! Please delete from the dataflow environment page")
91
113
 
92
- def remove_environment_from_db(env_name: str):
93
- """Remove environment information from LocalEnvironment table."""
114
+ def mark_environment_for_refresh(env_name: str):
115
+ """Mark environment for refresh via API."""
94
116
  try:
95
- db_generator = get_local_db()
96
- db = next(db_generator)
117
+ response = requests.put(
118
+ env_api,
119
+ params={"env_name": env_name},
120
+ json={"need_refresh": True},
121
+ timeout=30
122
+ )
97
123
 
98
- # Find and delete the environment
99
- existing_env = db.query(LocalEnvironment).filter_by(name=env_name).first()
100
- if existing_env:
101
- db.delete(existing_env)
102
- db.commit()
124
+ if response.status_code == 200:
125
+ logger.info(f"Environment '{env_name}' marked for refresh")
103
126
  else:
104
- logger.warning(f"Environment '{env_name}' not found in database")
127
+ logger.error(f"Error marking environment for refresh: {response.status_code} - {response.text}")
105
128
 
129
+ except requests.exceptions.RequestException as e:
130
+ logger.error(f"Network error marking environment for refresh: {str(e)}")
106
131
  except Exception as e:
107
- print(f"Error removing environment! Please delete from the dataflow enviornment page")
108
- logger.error(f"Error removing environment from database: {str(e)}")
109
- finally:
110
- db_generator.close()
132
+ logger.error(f"Unexpected error marking environment for refresh: {str(e)}")
111
133
 
112
134
  def package_operations(command: str):
113
135
  """Track conda install/remove/update commands for packages and update libraries in database."""
@@ -117,27 +139,13 @@ def package_operations(command: str):
117
139
  # to catch env removal
118
140
  if not os.path.exists(target_prefix):
119
141
  if is_local_environment(target_prefix) and env_name:
120
- remove_environment_from_db(env_name)
142
+ remove_environment(env_name)
121
143
  return
122
144
 
123
145
  should_update_db = is_local_environment(target_prefix) and env_name
124
146
 
125
147
  if should_update_db:
126
- try:
127
- db_generator = get_local_db()
128
- db = next(db_generator)
129
-
130
- # Find the environment and set need_refresh to True
131
- existing_env = db.query(LocalEnvironment).filter_by(name=env_name).first()
132
- if existing_env:
133
- existing_env.need_refresh = True
134
- existing_env.updated_at = datetime.now(timezone.utc)
135
- db.commit()
136
-
137
- except Exception as e:
138
- logger.error(f"Error updating need_refresh in database: {str(e)}")
139
- finally:
140
- db_generator.close()
148
+ mark_environment_for_refresh(env_name)
141
149
 
142
150
  @plugins.hookimpl
143
151
  def conda_post_commands():
@@ -4,12 +4,12 @@ conda_env_path=$1
4
4
 
5
5
  py_version=$(${conda_env_path}/bin/python -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
6
6
 
7
- ${conda_env_path}/bin/pip install dash==3.0.3 dash-renderer==1.9.1 plotly==6.0.1 typing==3.7.4.3 streamlit==1.45.1 ipython==9.2.0 ipykernel==6.29.5 ipython-sql==0.4.1 jupysql==0.10.14 psycopg2-binary==2.9.10 cryptography==44.0.3 dataflow-core dataflow-dbt
7
+ ${conda_env_path}/bin/pip install dash==3.0.3 dash-renderer==1.9.1 plotly==6.0.1 typing==3.7.4.3 streamlit==1.45.1 ipython==9.2.0 ipykernel==6.29.5 ipython-sql==0.4.1 jupysql==0.10.14 psycopg2-binary==2.9.10 cryptography==44.0.3 dataflow-core==2.1.11 dataflow-dbt==0.0.3
8
8
 
9
9
  # 3. Install Dataflow Airflow to a separate path in environment
10
10
  ${conda_env_path}/bin/pip install \
11
11
  --force-reinstall --root-user-action ignore \
12
- --no-warn-conflicts dataflow-airflow \
12
+ --no-warn-conflicts dataflow-airflow==2.10.7 \
13
13
  --target ${conda_env_path}/bin/airflow-libraries/
14
14
 
15
15
  files=(
@@ -1,8 +0,0 @@
1
- plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- plugin/plugin.py,sha256=ubvJ7Zu_iMfOxVGHNgU_OtrXgx8zc7bCUsv1NJ_tda8,5516
3
- plugin/scripts/install_dataflow_deps.sh,sha256=sbr4tbtjCE4nSKnn-Net4e73ZGGi1WWqkzQrU7_nZJI,1099
4
- dataflow_conda_plugin-0.1.3rc1.dist-info/METADATA,sha256=VSNCzwWj974IkvGOUvfVs5Lrj-fAQmDvWsbCiCNyLMk,68
5
- dataflow_conda_plugin-0.1.3rc1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- dataflow_conda_plugin-0.1.3rc1.dist-info/entry_points.txt,sha256=Vk2GKuQjr-5WV4NDKyPsnF37p3LUoAgPYOSMHxnpac8,46
7
- dataflow_conda_plugin-0.1.3rc1.dist-info/top_level.txt,sha256=Io_dflkI6h0vZSGOzZxx4e76CDTSANVfu4v4tVY6zsA,7
8
- dataflow_conda_plugin-0.1.3rc1.dist-info/RECORD,,