Skip to content

Commit

Permalink
remove make_db_session_factory
Browse files Browse the repository at this point in the history
Signed-off-by: Huong Nguyen <[email protected]>
  • Loading branch information
Huong Nguyen committed Dec 3, 2024
1 parent 2fb3576 commit ab66d10
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 71 deletions.
18 changes: 0 additions & 18 deletions package/kedro_viz/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,3 @@ def configure_wal_for_azure(engine):
if is_azure_ml:
with engine.connect() as conn:
conn.execute(text("PRAGMA journal_mode=WAL;"))


def make_db_session_factory(session_store_location: str) -> sessionmaker:
"""SQLAlchemy connection to a SQLite DB"""
database_url = f"sqlite:///{session_store_location}"
engine = create_engine(database_url, connect_args={"check_same_thread": False})
# TODO: making db session factory shouldn't depend on models.
# So want to move the table creation elsewhere ideally.
# But this means returning engine as well as session class.

# Check if we are running in an Azure ML environment if so enable WAL mode.
configure_wal_for_azure(engine)

# Create the database tables if they do not exist.
Base.metadata.create_all(bind=engine)

# Return a session factory bound to the engine.
return sessionmaker(bind=engine)
3 changes: 1 addition & 2 deletions package/kedro_viz/integrations/kedro/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ def load_data(
configuration.
is_lite: A flag to run Kedro-Viz in lite mode.
Returns:
A tuple containing the data catalog, pipeline dictionary, session store
and dataset stats dictionary.
A tuple containing the data catalog, pipeline dictionary,and dataset stats dictionary.
"""
if package_name:
configure_project(package_name)
Expand Down
1 change: 0 additions & 1 deletion package/kedro_viz/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from kedro_viz.autoreload_file_filter import AutoreloadFileFilter
from kedro_viz.constants import DEFAULT_HOST, DEFAULT_PORT
from kedro_viz.data_access import DataAccessManager, data_access_manager
from kedro_viz.database import make_db_session_factory
from kedro_viz.integrations.kedro import data_loader as kedro_data_loader
from kedro_viz.launchers.utils import _check_viz_up, _wait_for, display_cli_message

Expand Down
50 changes: 0 additions & 50 deletions package/tests/test_api/test_graphql/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,9 @@
from kedro_datasets import matplotlib, pandas, plotly, tracking

from kedro_viz.api.graphql.types import Run
from kedro_viz.database import make_db_session_factory
from kedro_viz.models.experiment_tracking import RunModel, UserRunDetailsModel


@pytest.fixture
def example_run_ids():
yield ["2021-11-03T18.24.24.379Z", "2021-11-02T18.24.24.379Z"]


@pytest.fixture
def example_db_session(tmp_path):
session_store_location = Path(tmp_path / "session_store.db")
session_class = make_db_session_factory(session_store_location)
yield session_class


@pytest.fixture
def example_db_session_with_runs(example_db_session, example_run_ids):
with example_db_session.begin() as session:
for run_id in example_run_ids:
session_data = {
"package_name": "testsql",
"project_path": "/Users/Projects/testsql",
"session_id": run_id,
"cli": {
"args": [],
"params": {
"from_inputs": [],
"to_outputs": [],
"from_nodes": [],
"to_nodes": [],
"node_names": (),
"runner": None,
"parallel": False,
"is_async": False,
"env": None,
"tag": (),
"load_version": {},
"pipeline": None,
"config": None,
"params": {},
},
"command_name": "run",
"command_path": "kedro run",
},
}
run = RunModel(id=run_id, blob=json.dumps(session_data))
user_run_details = UserRunDetailsModel(run_id=run.id, bookmark=True)
session.add(run)
session.add(user_run_details)
yield example_db_session


@pytest.fixture
def data_access_manager_with_no_run(data_access_manager, example_db_session, mocker):
data_access_manager.set_db_session(example_db_session)
Expand Down

0 comments on commit ab66d10

Please sign in to comment.