New modal, and space for sessions
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Guillem Borrell 2024-05-26 11:00:30 +02:00
parent 524aca0d96
commit a4135228f1
2 changed files with 62 additions and 7 deletions

View file

@ -65,7 +65,9 @@ class DDB:
return self return self
def dump_gcs(self, bucketname, sid) -> Self: def dump_gcs(self, bucketname, sid) -> Self:
self.db.sql(f"copy metadata to 'gcs://{bucketname}/{sid}/metadata.csv'") self.db.sql(
f"copy metadata to 'gcs://{bucketname}/sessions/{sid}/metadata.csv'"
)
for sheet in self.sheets: for sheet in self.sheets:
self.db.query(f""" self.db.query(f"""
@ -80,7 +82,7 @@ class DDB:
layer = '{sheet}' layer = '{sheet}'
) )
) )
to 'gcs://{bucketname}/{sid}/{sheet}.csv' to 'gcs://{bucketname}/sessions/{sid}/{sheet}.csv'
""") """)
return self return self
@ -88,7 +90,14 @@ class DDB:
def load_folder_local(self, path: str) -> Self: def load_folder_local(self, path: str) -> Self:
self.sheets = tuple( self.sheets = tuple(
self.query( self.query(
f"select Field2 from read_csv_auto('{path}/metadata.csv') where Field1 = 'Sheets'" f"""
select
Field2
from
read_csv_auto('{path}/metadata.csv')
where
Field1 = 'Sheets'
"""
) )
.fetchall()[0][0] .fetchall()[0][0]
.split(";") .split(";")
@ -110,7 +119,16 @@ class DDB:
def load_folder_gcs(self, bucketname: str, sid: str) -> Self: def load_folder_gcs(self, bucketname: str, sid: str) -> Self:
self.sheets = tuple( self.sheets = tuple(
self.query( self.query(
f"select Field2 from read_csv_auto('gcs://{bucketname}/{sid}/metadata.csv') where Field1 = 'Sheets'" f"""
select
Field2
from
read_csv_auto(
'gcs://{bucketname}/sessions/{sid}/metadata.csv'
)
where
Field1 = 'Sheets'
"""
) )
.fetchall()[0][0] .fetchall()[0][0]
.split(";") .split(";")
@ -123,7 +141,7 @@ class DDB:
select select
* *
from from
read_csv_auto('gcs://{bucketname}/{sid}/{sheet}.csv') read_csv_auto('gcs://{bucketname}/sessions/{sid}/{sheet}.csv')
) )
""") """)
@ -131,12 +149,24 @@ class DDB:
def load_description_local(self, path: str) -> Self: def load_description_local(self, path: str) -> Self:
return self.query( return self.query(
f"select Field2 from read_csv_auto('{path}/metadata.csv') where Field1 = 'Description'" f"""
select
Field2
from
read_csv_auto('{path}/metadata.csv')
where
Field1 = 'Description'"""
).fetchall()[0][0] ).fetchall()[0][0]
def load_description_gcs(self, bucketname: str, sid: str) -> Self: def load_description_gcs(self, bucketname: str, sid: str) -> Self:
return self.query( return self.query(
f"select Field2 from read_csv_auto('gcs://{bucketname}/{sid}/metadata.csv') where Field1 = 'Description'" f"""
select
Field2
from
read_csv_auto('gcs://{bucketname}/sessions/{sid}/metadata.csv')
where
Field1 = 'Description'"""
).fetchall()[0][0] ).fetchall()[0][0]
@staticmethod @staticmethod

View file

@ -74,6 +74,31 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
Or load an existing session
</button>
<!-- Modal -->
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false"
tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Current sessions</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Current sessions</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div> </div>
<div class="container chat-wrapper mt-4"> <div class="container chat-wrapper mt-4">
<div class="chat-container"> <div class="chat-container">