dataflow-core 2.1.5__tar.gz → 2.1.7__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.
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/PKG-INFO +1 -1
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/authenticator/dataflowhubauthenticator.py +0 -1
- dataflow_core-2.1.7/dataflow/db.py +91 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/__init__.py +4 -3
- dataflow_core-2.1.7/dataflow/models/dataflow_zone.py +19 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/environment.py +14 -2
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/pinned_projects.py +2 -2
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/project_details.py +1 -1
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/recent_projects.py +1 -1
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/role.py +12 -2
- dataflow_core-2.1.7/dataflow/models/role_zone.py +17 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/server_config.py +1 -1
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/user.py +4 -3
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/utils/get_current_user.py +2 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow_core.egg-info/PKG-INFO +1 -1
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow_core.egg-info/SOURCES.txt +2 -1
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/setup.py +1 -1
- dataflow_core-2.1.5/dataflow/db.py +0 -51
- dataflow_core-2.1.5/dataflow/models/runtime.py +0 -11
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/README.md +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/authenticator/__init__.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/authenticator/dataflowairflowauthenticator.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/authenticator/dataflowsupersetauthenticator.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/__init__.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/configuration.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/database_manager.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/dataflow.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/environment.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/app_types.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/blacklist_library.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/connection.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/environment_status.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/git_ssh.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/recent_project_studio.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/role_server.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/session.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/team.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/user_environment.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/user_team.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/models/variables.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/scripts/clone_environment.sh +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/scripts/create_environment.sh +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/scripts/update_environment.sh +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/utils/__init__.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/utils/aws_secrets_manager.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/utils/json_handler.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow/utils/logger.py +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow_core.egg-info/dependency_links.txt +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow_core.egg-info/entry_points.txt +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow_core.egg-info/requires.txt +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/dataflow_core.egg-info/top_level.txt +0 -0
- {dataflow_core-2.1.5 → dataflow_core-2.1.7}/setup.cfg +0 -0
|
@@ -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()
|
|
@@ -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,8 +11,9 @@ 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
|
|
15
|
-
from .
|
|
14
|
+
from .server_config import ServerConfig, CustomServerConfig
|
|
15
|
+
from .dataflow_zone import DataflowZone
|
|
16
|
+
from .role_zone import RoleZone
|
|
16
17
|
from .environment_status import EnvironmentStatus
|
|
17
18
|
from .user_team import UserTeam
|
|
18
19
|
from .role_server import RoleServer
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from sqlalchemy import Column, Integer, String, Boolean
|
|
2
|
+
from sqlalchemy.orm import relationship
|
|
3
|
+
from dataflow.db import Base
|
|
4
|
+
|
|
5
|
+
class DataflowZone(Base):
|
|
6
|
+
__tablename__ = "DATAFLOW_ZONE"
|
|
7
|
+
|
|
8
|
+
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
9
|
+
slug = Column(String, unique=True, nullable=False)
|
|
10
|
+
display_name = Column(String, nullable=False)
|
|
11
|
+
is_runtime = Column(Boolean, default=False)
|
|
12
|
+
subdomain = Column(String)
|
|
13
|
+
spark_enabled = Column(Boolean, default=False)
|
|
14
|
+
display_order = Column(Integer, default=0)
|
|
15
|
+
|
|
16
|
+
role_zone_assocs = relationship("RoleZone", back_populates="zone")
|
|
17
|
+
|
|
18
|
+
def __repr__(self):
|
|
19
|
+
return f"<DataflowZone(id={self.id}, slug='{self.slug}', display_name='{self.display_name}', display_order={self.display_order})>"
|
|
@@ -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
|
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
from sqlalchemy import Column, Integer, String, Enum
|
|
3
3
|
from sqlalchemy.orm import relationship
|
|
4
4
|
from dataflow.db import Base
|
|
5
|
+
import enum
|
|
6
|
+
|
|
7
|
+
class BaseRoleField(enum.Enum):
|
|
8
|
+
admin = "admin"
|
|
9
|
+
user = "user"
|
|
10
|
+
applicant = "applicant"
|
|
5
11
|
|
|
6
12
|
class Role(Base):
|
|
7
13
|
"""
|
|
@@ -13,7 +19,11 @@ class Role(Base):
|
|
|
13
19
|
id = Column(Integer, primary_key=True, index=True, autoincrement=True, nullable=False)
|
|
14
20
|
name = Column(String, unique=True, nullable=False)
|
|
15
21
|
description = Column(String, nullable=True)
|
|
16
|
-
base_role = Column(Enum(
|
|
22
|
+
base_role = Column(Enum(BaseRoleField), nullable=False, default=BaseRoleField.user)
|
|
17
23
|
|
|
18
24
|
users = relationship("User", back_populates="role_details", cascade="all, delete-orphan")
|
|
19
|
-
role_server_assocs = relationship("RoleServer", back_populates="role")
|
|
25
|
+
role_server_assocs = relationship("RoleServer", back_populates="role")
|
|
26
|
+
role_zone_assocs = relationship("RoleZone", back_populates="role")
|
|
27
|
+
|
|
28
|
+
def __repr__(self):
|
|
29
|
+
return f"<Role(id={self.id}, name='{self.name}', base_role='{self.base_role}')>"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import Dict, List, Optional
|
|
2
|
+
from sqlalchemy import Column, Integer, ForeignKey, UniqueConstraint, Boolean
|
|
3
|
+
from sqlalchemy.orm import relationship
|
|
4
|
+
from dataflow.db import Base
|
|
5
|
+
|
|
6
|
+
class RoleZone(Base):
|
|
7
|
+
__tablename__ = 'ROLE_ZONE'
|
|
8
|
+
|
|
9
|
+
role_id = Column(Integer, ForeignKey('ROLE.id', ondelete="CASCADE"), primary_key=True)
|
|
10
|
+
zone_id = Column(Integer, ForeignKey('DATAFLOW_ZONE.id', ondelete="CASCADE"), primary_key=True)
|
|
11
|
+
is_default = Column(Boolean, default=False, nullable=False)
|
|
12
|
+
|
|
13
|
+
role = relationship("Role", back_populates="role_zone_assocs")
|
|
14
|
+
zone = relationship("DataflowZone", back_populates="role_zone_assocs")
|
|
15
|
+
|
|
16
|
+
def __repr__(self):
|
|
17
|
+
return f"<RoleZone(role_id={self.role_id}, zone_id={self.zone_id}, is_default={self.is_default})>"
|
|
@@ -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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""models.py"""
|
|
2
|
-
from sqlalchemy import Column, Integer, String, Boolean, LargeBinary,
|
|
2
|
+
from sqlalchemy import Column, Integer, String, Boolean, LargeBinary, ForeignKey
|
|
3
3
|
from sqlalchemy.orm import relationship
|
|
4
4
|
from dataflow.db import Base
|
|
5
5
|
|
|
@@ -18,9 +18,10 @@ class User(Base):
|
|
|
18
18
|
role_id = Column(Integer, ForeignKey('ROLE.id'), nullable=False)
|
|
19
19
|
image = Column(LargeBinary)
|
|
20
20
|
image_url = Column(String, nullable=True)
|
|
21
|
-
active = Column(
|
|
21
|
+
active = Column(Boolean, nullable=False, default=True)
|
|
22
22
|
password = Column(String, nullable=False)
|
|
23
|
-
active_env = Column(String
|
|
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
|
|
|
@@ -26,9 +26,11 @@ def get_user_from_session(session_id: str, db: Session):
|
|
|
26
26
|
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="User not found")
|
|
27
27
|
|
|
28
28
|
base_role = user.role_details.base_role
|
|
29
|
+
role_id = user.role_details.id
|
|
29
30
|
role_name = user.role_details.name
|
|
30
31
|
user.base_role = base_role
|
|
31
32
|
user.role = role_name
|
|
33
|
+
user.role_id = role_id
|
|
32
34
|
|
|
33
35
|
return user
|
|
34
36
|
|
|
@@ -14,6 +14,7 @@ dataflow/models/__init__.py
|
|
|
14
14
|
dataflow/models/app_types.py
|
|
15
15
|
dataflow/models/blacklist_library.py
|
|
16
16
|
dataflow/models/connection.py
|
|
17
|
+
dataflow/models/dataflow_zone.py
|
|
17
18
|
dataflow/models/environment.py
|
|
18
19
|
dataflow/models/environment_status.py
|
|
19
20
|
dataflow/models/git_ssh.py
|
|
@@ -23,7 +24,7 @@ dataflow/models/recent_project_studio.py
|
|
|
23
24
|
dataflow/models/recent_projects.py
|
|
24
25
|
dataflow/models/role.py
|
|
25
26
|
dataflow/models/role_server.py
|
|
26
|
-
dataflow/models/
|
|
27
|
+
dataflow/models/role_zone.py
|
|
27
28
|
dataflow/models/server_config.py
|
|
28
29
|
dataflow/models/session.py
|
|
29
30
|
dataflow/models/team.py
|
|
@@ -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()
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
from sqlalchemy import Column, Integer, String, Boolean
|
|
2
|
-
from dataflow.db import Base
|
|
3
|
-
|
|
4
|
-
class RuntimeZone(Base):
|
|
5
|
-
__tablename__ = "RUNTIME_ZONE"
|
|
6
|
-
|
|
7
|
-
id = Column(Integer, primary_key=True, autoincrement=True, unique=True)
|
|
8
|
-
name = Column(String, unique=True, nullable=False)
|
|
9
|
-
display_name = Column(String, nullable=False)
|
|
10
|
-
display_order = Column(Integer)
|
|
11
|
-
spark_enabled = Column(Boolean, default=False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|