Spaces:
Running
Running
Push
Browse files- core/query_params.py +14 -5
- views/files.py +1 -1
- views/load.py +1 -1
- views/splash.py +3 -6
- views/wizard.py +0 -3
core/query_params.py
CHANGED
@@ -37,14 +37,23 @@ def go_to_tab(tabs: list[str]):
|
|
37 |
params = st.experimental_get_query_params()
|
38 |
if QueryParams.OPEN_TAB in params:
|
39 |
try:
|
40 |
-
|
41 |
-
if 0 <=
|
42 |
-
|
43 |
# Click on the tab.
|
44 |
js = f"""
|
45 |
<script>
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
</script>
|
49 |
"""
|
50 |
st.components.v1.html(js)
|
|
|
37 |
params = st.experimental_get_query_params()
|
38 |
if QueryParams.OPEN_TAB in params:
|
39 |
try:
|
40 |
+
index = int(params[QueryParams.OPEN_TAB][0])
|
41 |
+
if 0 <= index and index < len(TABS):
|
42 |
+
tab = TABS[index]
|
43 |
# Click on the tab.
|
44 |
js = f"""
|
45 |
<script>
|
46 |
+
function contains(selector, text) {{
|
47 |
+
const document = window.parent.document;
|
48 |
+
const elements = document.querySelectorAll(selector);
|
49 |
+
return Array.from(elements).filter(function(element) {{
|
50 |
+
return RegExp(text).test(element.innerText);
|
51 |
+
}});
|
52 |
+
}}
|
53 |
+
const tab = contains('button', '{tab}');
|
54 |
+
if (tab.length) {{
|
55 |
+
tab[0].click();
|
56 |
+
}}
|
57 |
</script>
|
58 |
"""
|
59 |
st.components.v1.html(js)
|
views/files.py
CHANGED
@@ -69,7 +69,7 @@ def _render_resources_panel(files: list[Resource]) -> Resource | None:
|
|
69 |
if not name:
|
70 |
return None
|
71 |
file = filename_to_file[name]
|
72 |
-
|
73 |
return file
|
74 |
|
75 |
|
|
|
69 |
if not name:
|
70 |
return None
|
71 |
file = filename_to_file[name]
|
72 |
+
set_tab(RESOURCES)
|
73 |
return file
|
74 |
|
75 |
|
views/load.py
CHANGED
@@ -21,7 +21,7 @@ def _on_file_upload(key):
|
|
21 |
try:
|
22 |
dataset = mlc.Dataset(newfile_name)
|
23 |
st.session_state[Metadata] = Metadata.from_canonical(dataset.metadata)
|
24 |
-
|
25 |
except mlc.ValidationError as e:
|
26 |
st.warning(e)
|
27 |
st.toast(body="Invalid Croissant File!", icon="🔥")
|
|
|
21 |
try:
|
22 |
dataset = mlc.Dataset(newfile_name)
|
23 |
st.session_state[Metadata] = Metadata.from_canonical(dataset.metadata)
|
24 |
+
save_current_project()
|
25 |
except mlc.ValidationError as e:
|
26 |
st.warning(e)
|
27 |
st.toast(body="Invalid Croissant File!", icon="🔥")
|
views/splash.py
CHANGED
@@ -4,6 +4,7 @@ import requests
|
|
4 |
import streamlit as st
|
5 |
|
6 |
from core.constants import OAUTH_CLIENT_ID
|
|
|
7 |
from core.query_params import set_project
|
8 |
from core.state import CurrentProject
|
9 |
from core.state import Metadata
|
@@ -28,9 +29,7 @@ def render_splash():
|
|
28 |
|
29 |
def create_new_croissant():
|
30 |
st.session_state[Metadata] = Metadata()
|
31 |
-
|
32 |
-
st.session_state[CurrentProject] = project
|
33 |
-
set_project(project)
|
34 |
|
35 |
st.button(
|
36 |
"Create",
|
@@ -45,9 +44,7 @@ def render_splash():
|
|
45 |
json = requests.get(url).json()
|
46 |
metadata = mlc.Metadata.from_json(mlc.Issues(), json, None)
|
47 |
st.session_state[Metadata] = Metadata.from_canonical(metadata)
|
48 |
-
|
49 |
-
st.session_state[CurrentProject] = project
|
50 |
-
set_project(project)
|
51 |
except Exception as exception:
|
52 |
logging.error(exception)
|
53 |
st.error(
|
|
|
4 |
import streamlit as st
|
5 |
|
6 |
from core.constants import OAUTH_CLIENT_ID
|
7 |
+
from core.past_projects import save_current_project
|
8 |
from core.query_params import set_project
|
9 |
from core.state import CurrentProject
|
10 |
from core.state import Metadata
|
|
|
29 |
|
30 |
def create_new_croissant():
|
31 |
st.session_state[Metadata] = Metadata()
|
32 |
+
save_current_project()
|
|
|
|
|
33 |
|
34 |
st.button(
|
35 |
"Create",
|
|
|
44 |
json = requests.get(url).json()
|
45 |
metadata = mlc.Metadata.from_json(mlc.Issues(), json, None)
|
46 |
st.session_state[Metadata] = Metadata.from_canonical(metadata)
|
47 |
+
save_current_project()
|
|
|
|
|
48 |
except Exception as exception:
|
49 |
logging.error(exception)
|
50 |
st.error(
|
views/wizard.py
CHANGED
@@ -5,10 +5,7 @@ import streamlit_nested_layout # Do not remove this allows nesting columns.
|
|
5 |
|
6 |
from core.constants import TABS
|
7 |
from core.past_projects import save_current_project
|
8 |
-
from core.query_params import get_project_timestamp
|
9 |
from core.query_params import go_to_tab
|
10 |
-
from core.query_params import QueryParams
|
11 |
-
from core.query_params import set_tab
|
12 |
from core.state import Metadata
|
13 |
import mlcroissant as mlc
|
14 |
from views.files import render_files
|
|
|
5 |
|
6 |
from core.constants import TABS
|
7 |
from core.past_projects import save_current_project
|
|
|
8 |
from core.query_params import go_to_tab
|
|
|
|
|
9 |
from core.state import Metadata
|
10 |
import mlcroissant as mlc
|
11 |
from views.files import render_files
|