From 76601238d4d917c331818f7caacfc705c22bf7d6 Mon Sep 17 00:00:00 2001 From: Vedant P Iyer Date: Wed, 27 Nov 2024 13:19:57 -0700 Subject: [PATCH] add extra install to github CI file --- .github/workflows/test_sqlite.yml | 1 + dsi/backends/sqlite.py | 74 +++++++++---------------------- 2 files changed, 23 insertions(+), 52 deletions(-) diff --git a/.github/workflows/test_sqlite.yml b/.github/workflows/test_sqlite.yml index 9fdd3b7..b402b5c 100644 --- a/.github/workflows/test_sqlite.yml +++ b/.github/workflows/test_sqlite.yml @@ -27,6 +27,7 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt pip install . + pip install ipykernel - name: Test reader run: | pip install pytest diff --git a/dsi/backends/sqlite.py b/dsi/backends/sqlite.py index 9cde8f8..8c664aa 100644 --- a/dsi/backends/sqlite.py +++ b/dsi/backends/sqlite.py @@ -238,75 +238,45 @@ def inspect_artifacts(self, collection, interactive=False): import pandas as pd import sqlite3 """ - # code2 = f"""\ - # dbPath = '{self.filename}' - # conn = sqlite3.connect(dbPath) - # tables = pd.read_sql_query('SELECT name FROM sqlite_master WHERE type="table";', conn) - # """ - # if dsi_units is not None: - # code2 += f"""dsi_units = {dsi_units} - # """ - # if dsi_relations is not None: - # code2 += f"""dsi_relations = {dsi_relations} - # """ - - # code3 = """\ - # table_list = [] - # for table_name in tables['name']: - # if table_name not in [""" - # if dsi_units is not None: - # code3 += "'dsi_units', " - # if dsi_relations is not None: - # code3 += "'dsi_relations', " - # code3+="""'sqlite_sequence']: - # query = 'SELECT * FROM ' + table_name - # df = pd.read_sql_query(query, conn) - # df.attrs['name'] = table_name - # """ - # if dsi_units is not None: - # code3+= """if table_name in dsi_units: - # df.attrs['units'] = dsi_units[table_name] - # """ - # code3+= """table_list.append(df) - # """ - - # if dsi_relations is not None: - # code3+= """ - # df = pd.DataFrame(dsi_relations) - # df.attrs['name'] = 'dsi_relations' - # table_list.append(df) - # """ - - # code4 = """\ - # for table_df in table_list: - # print(table_df.attrs) - # print(table_df) - # # table_df.info() - # # table_df.describe() - # """ - code2 = f"""\ dbPath = '{self.filename}' conn = sqlite3.connect(dbPath) tables = pd.read_sql_query('SELECT name FROM sqlite_master WHERE type="table";', conn) - dsi_units = {dsi_units} - dsi_relations = {dsi_relations} """ + if dsi_units is not None: + code2 += f"""dsi_units = {dsi_units} + """ + if dsi_relations is not None: + code2 += f"""dsi_relations = {dsi_relations} + """ + code3 = """\ table_list = [] for table_name in tables['name']: - if table_name not in ['dsi_relations', 'dsi_units', 'sqlite_sequence']: + if table_name not in [""" + if dsi_units is not None: + code3 += "'dsi_units', " + if dsi_relations is not None: + code3 += "'dsi_relations', " + code3+="""'sqlite_sequence']: query = 'SELECT * FROM ' + table_name df = pd.read_sql_query(query, conn) df.attrs['name'] = table_name - if table_name in dsi_units: + """ + if dsi_units is not None: + code3+= """if table_name in dsi_units: df.attrs['units'] = dsi_units[table_name] - table_list.append(df) + """ + code3+= """table_list.append(df) + """ + if dsi_relations is not None: + code3+= """ df = pd.DataFrame(dsi_relations) df.attrs['name'] = 'dsi_relations' table_list.append(df) """ + code4 = """\ for table_df in table_list: print(table_df.attrs)