Spaces:
Sleeping
Sleeping
Vũ Thanh Hà
commited on
Commit
•
77d0a7c
1
Parent(s):
fdc17a0
Update 2_hf_repo_info.py
Browse files- 2_hf_repo_info.py +45 -15
2_hf_repo_info.py
CHANGED
@@ -2,15 +2,23 @@ import streamlit as st
|
|
2 |
from huggingface_hub import list_models
|
3 |
from datetime import date, timedelta, datetime, timezone
|
4 |
import pandas as pd
|
|
|
5 |
|
6 |
# os.environ["KAGGLE_USERNAME"] = "hahunavth"
|
7 |
# os.environ["KAGGLE_KEY"] = ""
|
8 |
from kaggle.api.kaggle_api_extended import KaggleApi
|
9 |
|
10 |
-
api = KaggleApi()
|
11 |
-
api.authenticate()
|
12 |
-
|
13 |
st.set_page_config(layout="wide")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# @st.cache_resource
|
15 |
# def get_model_list():
|
16 |
# return [model for model in list(list_models(author="hahunavth", filter="emofs2"))]
|
@@ -47,12 +55,6 @@ for model in models:
|
|
47 |
|
48 |
step = model.id.replace('hahunavth/emofs2-exp', '').split('_')[0]
|
49 |
|
50 |
-
kaggle_slug = f"ess-vlsp2023-train-{step}"
|
51 |
-
try:
|
52 |
-
kernel_status = api.kernel_status(user_name="hahunavth", kernel_slug="ess-vlsp2023-train-42")["status"]
|
53 |
-
except:
|
54 |
-
kernel_status = "not found"
|
55 |
-
|
56 |
_models.append(
|
57 |
{
|
58 |
"id": model.id,
|
@@ -60,19 +62,47 @@ for model in models:
|
|
60 |
"ckpt_list": last_ckpt,
|
61 |
"huggingface": f'https://huggingface.co/{model.id}/tree/main' if model.id else None,
|
62 |
"notebook": f"https://www.kaggle.com/code/hahunavth/ess-vlsp2023-train-{step}" if model.id else None,
|
63 |
-
"
|
64 |
-
"
|
|
|
|
|
65 |
}
|
66 |
)
|
67 |
|
68 |
-
|
69 |
df = pd.DataFrame(_models)
|
70 |
|
71 |
-
st.
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
column_config={
|
74 |
"huggingface": st.column_config.LinkColumn(),
|
75 |
"notebook": st.column_config.LinkColumn(),
|
|
|
76 |
},
|
77 |
-
use_container_width=True
|
78 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from huggingface_hub import list_models
|
3 |
from datetime import date, timedelta, datetime, timezone
|
4 |
import pandas as pd
|
5 |
+
import asyncio
|
6 |
|
7 |
# os.environ["KAGGLE_USERNAME"] = "hahunavth"
|
8 |
# os.environ["KAGGLE_KEY"] = ""
|
9 |
from kaggle.api.kaggle_api_extended import KaggleApi
|
10 |
|
|
|
|
|
|
|
11 |
st.set_page_config(layout="wide")
|
12 |
+
|
13 |
+
|
14 |
+
@st.cache_resource
|
15 |
+
def init_kaggle():
|
16 |
+
api = KaggleApi()
|
17 |
+
api.authenticate()
|
18 |
+
return api
|
19 |
+
|
20 |
+
api = init_kaggle()
|
21 |
+
|
22 |
# @st.cache_resource
|
23 |
# def get_model_list():
|
24 |
# return [model for model in list(list_models(author="hahunavth", filter="emofs2"))]
|
|
|
55 |
|
56 |
step = model.id.replace('hahunavth/emofs2-exp', '').split('_')[0]
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
_models.append(
|
59 |
{
|
60 |
"id": model.id,
|
|
|
62 |
"ckpt_list": last_ckpt,
|
63 |
"huggingface": f'https://huggingface.co/{model.id}/tree/main' if model.id else None,
|
64 |
"notebook": f"https://www.kaggle.com/code/hahunavth/ess-vlsp2023-train-{step}" if model.id else None,
|
65 |
+
"status": None,
|
66 |
+
"config": f"/kaggle/repo/vlsp2023-ess/config/exp{step}",
|
67 |
+
# "command": "st.balloons",
|
68 |
+
# "is_widget": True
|
69 |
}
|
70 |
)
|
71 |
|
|
|
72 |
df = pd.DataFrame(_models)
|
73 |
|
74 |
+
@st.cache_data
|
75 |
+
def get_kernel_status(step):
|
76 |
+
kaggle_slug = f"ess-vlsp2023-train-{step}"
|
77 |
+
try:
|
78 |
+
kernel_status = api.kernel_status(user_name="hahunavth", kernel_slug=kaggle_slug)["status"]
|
79 |
+
except:
|
80 |
+
kernel_status = "not found"
|
81 |
+
return kernel_status
|
82 |
+
|
83 |
+
async def set_df_kernel_status(df, n=12):
|
84 |
+
for i in range(min(len(df), n)):
|
85 |
+
step = df.iloc[i]["id"].replace('hahunavth/emofs2-exp', '').split('_')[0]
|
86 |
+
status = get_kernel_status(step)
|
87 |
+
df.at[i, "status"] = status
|
88 |
+
print(i, status)
|
89 |
+
|
90 |
+
asyncio.run(set_df_kernel_status(df))
|
91 |
+
|
92 |
+
edit_df = st.data_editor(
|
93 |
+
df,
|
94 |
column_config={
|
95 |
"huggingface": st.column_config.LinkColumn(),
|
96 |
"notebook": st.column_config.LinkColumn(),
|
97 |
+
# "a": st.button("Click me"),
|
98 |
},
|
|
|
99 |
)
|
100 |
+
|
101 |
+
# st.dataframe(
|
102 |
+
# edit_df,
|
103 |
+
# column_config={
|
104 |
+
# "huggingface": st.column_config.LinkColumn(),
|
105 |
+
# "notebook": st.column_config.LinkColumn(),
|
106 |
+
# },
|
107 |
+
# use_container_width=True
|
108 |
+
# )
|