dataflow-core 2.1.4__tar.gz → 2.1.6__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 dataflow-core might be problematic. Click here for more details.

Files changed (50) hide show
  1. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/PKG-INFO +1 -1
  2. dataflow_core-2.1.6/dataflow/db.py +91 -0
  3. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/environment.py +1 -1
  4. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/__init__.py +2 -2
  5. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/environment.py +14 -2
  6. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/pinned_projects.py +2 -2
  7. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/project_details.py +1 -1
  8. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/recent_projects.py +1 -1
  9. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/server_config.py +1 -1
  10. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/user.py +2 -1
  11. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow_core.egg-info/PKG-INFO +1 -1
  12. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/setup.py +1 -1
  13. dataflow_core-2.1.4/dataflow/db.py +0 -51
  14. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/README.md +0 -0
  15. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/authenticator/__init__.py +0 -0
  16. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/authenticator/dataflowairflowauthenticator.py +0 -0
  17. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/authenticator/dataflowhubauthenticator.py +0 -0
  18. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/authenticator/dataflowsupersetauthenticator.py +0 -0
  19. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/__init__.py +0 -0
  20. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/configuration.py +0 -0
  21. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/database_manager.py +0 -0
  22. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/dataflow.py +0 -0
  23. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/app_types.py +0 -0
  24. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/blacklist_library.py +0 -0
  25. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/connection.py +0 -0
  26. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/environment_status.py +0 -0
  27. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/git_ssh.py +0 -0
  28. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/recent_project_studio.py +0 -0
  29. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/role.py +0 -0
  30. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/role_server.py +0 -0
  31. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/runtime.py +0 -0
  32. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/session.py +0 -0
  33. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/team.py +0 -0
  34. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/user_environment.py +0 -0
  35. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/user_team.py +0 -0
  36. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/models/variables.py +0 -0
  37. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/scripts/clone_environment.sh +0 -0
  38. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/scripts/create_environment.sh +0 -0
  39. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/scripts/update_environment.sh +0 -0
  40. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/utils/__init__.py +0 -0
  41. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/utils/aws_secrets_manager.py +0 -0
  42. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/utils/get_current_user.py +0 -0
  43. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/utils/json_handler.py +0 -0
  44. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow/utils/logger.py +0 -0
  45. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow_core.egg-info/SOURCES.txt +0 -0
  46. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow_core.egg-info/dependency_links.txt +0 -0
  47. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow_core.egg-info/entry_points.txt +0 -0
  48. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow_core.egg-info/requires.txt +0 -0
  49. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/dataflow_core.egg-info/top_level.txt +0 -0
  50. {dataflow_core-2.1.4 → dataflow_core-2.1.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataflow-core
3
- Version: 2.1.4
3
+ Version: 2.1.6
4
4
  Summary: Dataflow core package
5
5
  Author: Dataflow
6
6
  Author-email:
@@ -0,0 +1,91 @@
1
+ import dataflow
2
+ from .database_manager import DatabaseManager
3
+ from .configuration import ConfigurationManager
4
+ from sqlalchemy.orm import declarative_base
5
+ from sqlalchemy.exc import SQLAlchemyError
6
+ from .utils.logger import CustomLogger
7
+ import os
8
+ import pwd
9
+ import grp
10
+ from urllib.parse import urlparse
11
+
12
+ logger = CustomLogger().get_logger(__name__)
13
+
14
+ dataflow_config = ConfigurationManager('/dataflow/app/config/dataflow.cfg')
15
+ dataflow_local_config = ConfigurationManager('/dataflow/app/auth_config/dataflow_auth.cfg')
16
+ db_url = dataflow_config.get_config_value('database', 'database_url')
17
+ local_db_url = dataflow_local_config.get_config_value('database', 'single_user_db_url')
18
+
19
+ db_manager = DatabaseManager(db_url)
20
+ local_db_manager = None
21
+
22
+ Base = declarative_base()
23
+ Local_Base = declarative_base()
24
+
25
+ def create_tables(local_db=False):
26
+ """
27
+ Create all tables in the database.
28
+ This is called at the start of the application.
29
+ """
30
+ try:
31
+ if local_db:
32
+ if local_db_url and local_db_url.startswith('sqlite:///'):
33
+ parsed_url = urlparse(local_db_url)
34
+ db_file_path = parsed_url.path
35
+ db_dir = os.path.dirname(db_file_path)
36
+ logger.info(f"Creating local database at: {db_file_path}")
37
+
38
+ if db_dir and not os.path.exists(db_dir):
39
+ os.makedirs(db_dir, exist_ok=True)
40
+ logger.info(f"Created directory for local database: {db_dir}")
41
+
42
+ # Set ownership for database directory and file
43
+ nb_user = os.environ.get("NB_USER")
44
+ if nb_user:
45
+ try:
46
+ uid = pwd.getpwnam(nb_user).pw_uid
47
+ gid = grp.getgrnam(nb_user).gr_gid
48
+
49
+ # Set ownership for database directory
50
+ if os.path.exists(db_dir):
51
+ os.chown(db_dir, uid, gid)
52
+
53
+ global local_db_manager
54
+ if local_db_manager is None:
55
+ local_db_manager = DatabaseManager(local_db_url)
56
+ Local_Base.metadata.create_all(bind=local_db_manager.get_engine())
57
+
58
+ if os.path.exists(db_file_path):
59
+ os.chown(db_file_path, uid, gid)
60
+ logger.info(f"Ownership set for local database files")
61
+ except (KeyError, OSError) as e:
62
+ logger.warning(f"Could not set ownership for database files: {e}")
63
+ else:
64
+ logger.error("NB_USER environment variable is not set. Cannot set ownership for local database files.")
65
+ raise ValueError("Can only use local database with a valid NB_USER environment variable")
66
+ else:
67
+ logger.error("Local database URL must be a valid SQLite URL starting with 'sqlite:///'")
68
+ raise ValueError("Local database URL must be a valid SQLite URL starting with 'sqlite:///'")
69
+
70
+ else:
71
+ Base.metadata.create_all(bind=db_manager.get_engine())
72
+ logger.info("Database tables created successfully")
73
+ except SQLAlchemyError as e:
74
+ error_message = f"Failed to create tables: {str(e)}"
75
+ logger.error(error_message)
76
+ raise e
77
+
78
+ def get_local_db():
79
+ """
80
+ Get a local database session.
81
+
82
+ Yields:
83
+ Session: Local database session
84
+ """
85
+ global local_db_manager
86
+ if local_db_manager is None:
87
+ local_db_manager = DatabaseManager(local_db_url)
88
+ yield from local_db_manager.get_session()
89
+
90
+ def get_db():
91
+ yield from db_manager.get_session()
@@ -108,7 +108,7 @@ class EnvironmentManager:
108
108
  yaml_file_path=yaml_path,
109
109
  source_path=source_path,
110
110
  log_file_location=log_file_location,
111
- version=1
111
+ version="1"
112
112
  )
113
113
 
114
114
  # Update job log status if db was provided
@@ -3,7 +3,7 @@
3
3
  from .role import Role
4
4
  from .user import User
5
5
  from .team import Team
6
- from .environment import Environment
6
+ from .environment import (Environment, LocalEnvironment, ArchivedEnvironment, JobLogs)
7
7
  from .project_details import ProjectDetails
8
8
  from .recent_projects import RecentProjects
9
9
  from .pinned_projects import PinnedProject
@@ -11,7 +11,7 @@ from .app_types import AppType
11
11
  from .blacklist_library import BlacklistedLibrary
12
12
  from .environment_status import EnvironmentStatus
13
13
  from .session import Session
14
- from .server_config import ServerConfig
14
+ from .server_config import ServerConfig, CustomServerConfig
15
15
  from .runtime import RuntimeZone
16
16
  from .environment_status import EnvironmentStatus
17
17
  from .user_team import UserTeam
@@ -1,8 +1,8 @@
1
1
  from sqlalchemy import Column, Integer, String, Boolean, Text, ForeignKey, DateTime
2
2
  from sqlalchemy.orm import relationship
3
3
  from sqlalchemy.sql import func
4
- from datetime import datetime
5
- from dataflow.db import Base
4
+ from datetime import datetime, timezone
5
+ from dataflow.db import Base, Local_Base
6
6
 
7
7
  class EnvironmentAttributes(Base):
8
8
  """
@@ -61,3 +61,15 @@ class JobLogs(Base):
61
61
  status = Column(String)
62
62
  created_by = Column(String)
63
63
 
64
+
65
+ class LocalEnvironment(Local_Base):
66
+ __tablename__ = "LOCAL_ENVIRONMENT"
67
+
68
+ id = Column(Integer, primary_key=True, autoincrement=True)
69
+ name = Column(String, nullable=False)
70
+ py_version = Column(String)
71
+ pip_libraries = Column(Text)
72
+ conda_libraries = Column(Text)
73
+ status = Column(String, default="Created")
74
+ updated_at = Column(DateTime, default=datetime.now(timezone.utc), onupdate=datetime.now(timezone.utc))
75
+ need_refresh = Column(Boolean, default=False)
@@ -6,8 +6,8 @@ class PinnedProject(Base):
6
6
  __tablename__ = "PINNED_PROJECT"
7
7
 
8
8
  id = Column(Integer, primary_key=True)
9
- user_id = Column(Integer, ForeignKey('USER.user_id'), index=True)
10
- project_id = Column(Integer, ForeignKey('PROJECT_DETAIL.project_id'), index=True)
9
+ user_id = Column(Integer, ForeignKey('USER.user_id', ondelete="CASCADE"), index=True)
10
+ project_id = Column(Integer, ForeignKey('PROJECT_DETAIL.project_id', ondelete="CASCADE"), index=True)
11
11
  pinned_at = Column(DateTime, default=datetime.utcnow)
12
12
 
13
13
  __table_args__ = (
@@ -10,7 +10,7 @@ class ProjectDetails(Base):
10
10
  git_url = Column(String)
11
11
  git_branch = Column(String, nullable=True)
12
12
  git_folder = Column(String, nullable=True)
13
- type = Column(String, ForeignKey('RUNTIME_APP_TYPE.name'), nullable=False)
13
+ type = Column(String, ForeignKey('RUNTIME_APP_TYPE.name', ondelete="CASCADE"), nullable=False)
14
14
  slug = Column(String, nullable=False, unique=True)
15
15
  runtime = Column(String, nullable=False)
16
16
  py_env = Column(String, nullable=True)
@@ -5,5 +5,5 @@ class RecentProjects(Base):
5
5
  __tablename__ = "RECENT_PROJECT"
6
6
 
7
7
  id = Column(Integer, primary_key=True, autoincrement=True)
8
- project_id = Column(Integer, ForeignKey('PROJECT_DETAIL.project_id'), nullable=False)
8
+ project_id = Column(Integer, ForeignKey('PROJECT_DETAIL.project_id', ondelete="CASCADE"), nullable=False)
9
9
 
@@ -24,7 +24,7 @@ class CustomServerConfig(Base):
24
24
  __tablename__ = "CUSTOM_SERVER"
25
25
 
26
26
  id = Column(Integer, primary_key=True, autoincrement=True)
27
- base_server_id = Column(Integer, ForeignKey(ServerConfig.id), nullable=False)
27
+ base_server_id = Column(Integer, ForeignKey(ServerConfig.id, ondelete="CASCADE"), nullable=False)
28
28
  display_name = Column(String, nullable=False, unique=True, index=True)
29
29
  description = Column(Text, nullable=True)
30
30
 
@@ -20,7 +20,8 @@ class User(Base):
20
20
  image_url = Column(String, nullable=True)
21
21
  active = Column(Enum('N', 'Y', name='active_field'), nullable=False, server_default=str("N"))
22
22
  password = Column(String, nullable=False)
23
- active_env = Column(String, ForeignKey('ENVIRONMENT.short_name'))
23
+ active_env = Column(String)
24
+ active_env_type = Column(String, nullable=True)
24
25
  current_server = Column(String)
25
26
  show_server_page = Column(Boolean, default = True)
26
27
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataflow-core
3
- Version: 2.1.4
3
+ Version: 2.1.6
4
4
  Summary: Dataflow core package
5
5
  Author: Dataflow
6
6
  Author-email:
@@ -14,7 +14,7 @@ class PostInstall(install):
14
14
 
15
15
  setup(
16
16
  name="dataflow-core",
17
- version="2.1.4",
17
+ version="2.1.6",
18
18
  packages=find_packages(include=["dataflow", "dataflow.*", "authenticator", "authenticator.*"]),
19
19
  include_package_data=True,
20
20
  package_data={
@@ -1,51 +0,0 @@
1
- from .database_manager import DatabaseManager
2
- from .configuration import ConfigurationManager
3
- from sqlalchemy.orm import declarative_base
4
- from sqlalchemy.exc import SQLAlchemyError
5
- from .utils.logger import CustomLogger
6
-
7
- logger = CustomLogger().get_logger(__name__)
8
-
9
- dataflow_config = ConfigurationManager('/dataflow/app/config/dataflow.cfg')
10
- db_url = dataflow_config.get_config_value('database', 'database_url')
11
- local_db_url = dataflow_config.get_config_value('database', 'single_user_db_url')
12
-
13
- db_manager = DatabaseManager(db_url)
14
- local_db_manager = None
15
-
16
- Base = declarative_base()
17
- Local_Base = declarative_base()
18
-
19
- def create_tables(local_db=False):
20
- """
21
- Create all tables in the database.
22
- This is called at the start of the application.
23
- """
24
- try:
25
- if local_db:
26
- global local_db_manager
27
- if local_db_manager is None:
28
- local_db_manager = DatabaseManager(local_db_url)
29
- Local_Base.metadata.create_all(bind=local_db_manager.get_engine())
30
- else:
31
- Base.metadata.create_all(bind=db_manager.get_engine())
32
- logger.info("Database tables created successfully")
33
- except SQLAlchemyError as e:
34
- error_message = f"Failed to create tables: {str(e)}"
35
- logger.error(error_message)
36
- raise e
37
-
38
- def get_local_db():
39
- """
40
- Get a local database session.
41
-
42
- Yields:
43
- Session: Local database session
44
- """
45
- global local_db_manager
46
- if local_db_manager is None:
47
- local_db_manager = DatabaseManager(local_db_url)
48
- yield from local_db_manager.get_session()
49
-
50
- def get_db():
51
- yield from db_manager.get_session()
File without changes
File without changes