Spaces:
Runtime error
Runtime error
Commit
·
a3f4230
1
Parent(s):
4214369
Push to HF space
Browse files
app.py
CHANGED
|
@@ -20,48 +20,48 @@ if 'dataset' in query_params:
|
|
| 20 |
def _dataset_page():
|
| 21 |
is_valid_dataset = False
|
| 22 |
|
| 23 |
-
st.header('Deploy a HuggingFace dataset to a space
|
| 24 |
st.subheader(
|
| 25 |
-
'Step 1:
|
| 26 |
divider='violet',
|
| 27 |
anchor=False,
|
| 28 |
help='For a list of datasets see: https://huggingface.co/datasets',
|
| 29 |
)
|
| 30 |
-
|
| 31 |
hf_dataset_name = st.text_input(
|
| 32 |
-
'
|
| 33 |
help='Either in the format `user/dataset` or `dataset`, for example: `Open-Orca/OpenOrca`',
|
| 34 |
placeholder='dataset or user/dataset',
|
| 35 |
value=st.session_state.get('hf_dataset_name', None),
|
| 36 |
)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
| 65 |
|
| 66 |
def _next():
|
| 67 |
st.session_state.current_page = 'space'
|
|
@@ -117,7 +117,7 @@ def _space_page():
|
|
| 117 |
|
| 118 |
_back_button()
|
| 119 |
st.subheader(
|
| 120 |
-
'Step 2:
|
| 121 |
divider='violet',
|
| 122 |
anchor=False,
|
| 123 |
help='See HuggingFace Spaces [documentation](https://huggingface.co/docs/hub/spaces-overview)',
|
|
@@ -129,15 +129,14 @@ def _space_page():
|
|
| 129 |
if st.session_state.get('sample_size', None):
|
| 130 |
st.write(f'Sample size: {session["sample_size"]}')
|
| 131 |
|
| 132 |
-
st.write('##### HuggingFace space to create')
|
| 133 |
hf_space_name = st.text_input(
|
| 134 |
-
'
|
| 135 |
help='This space will be created if it does not exist',
|
| 136 |
placeholder='org/name',
|
| 137 |
value=hf_space_name,
|
| 138 |
)
|
| 139 |
hf_access_token = st.text_input(
|
| 140 |
-
'
|
| 141 |
type='password',
|
| 142 |
help='The access token is used to authenticate you with HuggingFace to create the space. '
|
| 143 |
'https://huggingface.co/docs/hub/security-tokens',
|
|
@@ -145,9 +144,12 @@ def _space_page():
|
|
| 145 |
)
|
| 146 |
storage_options = ['None', 'small', 'medium', 'large']
|
| 147 |
hf_storage = st.selectbox(
|
| 148 |
-
'
|
| 149 |
['None', 'small', 'medium', 'large'],
|
| 150 |
-
help='
|
|
|
|
|
|
|
|
|
|
| 151 |
index=storage_options.index(hf_storage if hf_storage else 'None'),
|
| 152 |
)
|
| 153 |
|
|
@@ -224,12 +226,11 @@ dataset_name = st.session_state.get('ds_dataset_name', None) or st.session_state
|
|
| 224 |
'hf_dataset_name', None
|
| 225 |
)
|
| 226 |
if st.session_state.get('ds_loaded', False):
|
| 227 |
-
st.sidebar.write('# HuggingFace dataset')
|
| 228 |
-
|
| 229 |
st.sidebar.header(
|
| 230 |
f'[{dataset_name}](https://huggingface.co/datasets/{dataset_name})',
|
| 231 |
divider='rainbow',
|
| 232 |
anchor=False,
|
|
|
|
| 233 |
)
|
| 234 |
|
| 235 |
st.sidebar.write(st.session_state.get('ds_description', None))
|
|
|
|
| 20 |
def _dataset_page():
|
| 21 |
is_valid_dataset = False
|
| 22 |
|
| 23 |
+
st.header('Deploy Lilac for a HuggingFace dataset to a space', anchor=False)
|
| 24 |
st.subheader(
|
| 25 |
+
'Step 1: select a dataset',
|
| 26 |
divider='violet',
|
| 27 |
anchor=False,
|
| 28 |
help='For a list of datasets see: https://huggingface.co/datasets',
|
| 29 |
)
|
|
|
|
| 30 |
hf_dataset_name = st.text_input(
|
| 31 |
+
'dataset id',
|
| 32 |
help='Either in the format `user/dataset` or `dataset`, for example: `Open-Orca/OpenOrca`',
|
| 33 |
placeholder='dataset or user/dataset',
|
| 34 |
value=st.session_state.get('hf_dataset_name', None),
|
| 35 |
)
|
| 36 |
+
with st.expander('advanced options'):
|
| 37 |
+
hf_config_name = st.text_input(
|
| 38 |
+
'config',
|
| 39 |
+
help='Some datasets required this field.',
|
| 40 |
+
placeholder='(optional)',
|
| 41 |
+
value=st.session_state.get('hf_config_name', None),
|
| 42 |
+
)
|
| 43 |
+
hf_split = st.text_input(
|
| 44 |
+
'split',
|
| 45 |
+
help='Loads all splits by default.',
|
| 46 |
+
placeholder='(optional)',
|
| 47 |
+
value=st.session_state.get('hf_split', None),
|
| 48 |
+
)
|
| 49 |
+
sample_size = st.number_input(
|
| 50 |
+
'sample size',
|
| 51 |
+
help='Number of rows to sample from the dataset, for each split.',
|
| 52 |
+
placeholder='(optional)',
|
| 53 |
+
min_value=1,
|
| 54 |
+
step=1,
|
| 55 |
+
key='sample_size',
|
| 56 |
+
value=st.session_state.get('sample_size', None),
|
| 57 |
+
)
|
| 58 |
+
hf_read_token = st.text_input(
|
| 59 |
+
'huggingface [read token](https://huggingface.co/settings/tokens)',
|
| 60 |
+
type='password',
|
| 61 |
+
help='The access token is used to authenticate you with HuggingFace to read the dataset. '
|
| 62 |
+
'https://huggingface.co/docs/hub/security-tokens',
|
| 63 |
+
placeholder='(optional if dataset is public)',
|
| 64 |
+
)
|
| 65 |
|
| 66 |
def _next():
|
| 67 |
st.session_state.current_page = 'space'
|
|
|
|
| 117 |
|
| 118 |
_back_button()
|
| 119 |
st.subheader(
|
| 120 |
+
'Step 2: create huggingface space',
|
| 121 |
divider='violet',
|
| 122 |
anchor=False,
|
| 123 |
help='See HuggingFace Spaces [documentation](https://huggingface.co/docs/hub/spaces-overview)',
|
|
|
|
| 129 |
if st.session_state.get('sample_size', None):
|
| 130 |
st.write(f'Sample size: {session["sample_size"]}')
|
| 131 |
|
|
|
|
| 132 |
hf_space_name = st.text_input(
|
| 133 |
+
'space id',
|
| 134 |
help='This space will be created if it does not exist',
|
| 135 |
placeholder='org/name',
|
| 136 |
value=hf_space_name,
|
| 137 |
)
|
| 138 |
hf_access_token = st.text_input(
|
| 139 |
+
'huggingface [write token](https://huggingface.co/settings/tokens)',
|
| 140 |
type='password',
|
| 141 |
help='The access token is used to authenticate you with HuggingFace to create the space. '
|
| 142 |
'https://huggingface.co/docs/hub/security-tokens',
|
|
|
|
| 144 |
)
|
| 145 |
storage_options = ['None', 'small', 'medium', 'large']
|
| 146 |
hf_storage = st.selectbox(
|
| 147 |
+
'persistent storage',
|
| 148 |
['None', 'small', 'medium', 'large'],
|
| 149 |
+
help='Persistent storage is required if you want data to persist past the lifetime of the '
|
| 150 |
+
'space docker image. This is recommended when running computations like signals or embeddings,'
|
| 151 |
+
'or if you want labels to persist. You will get charged for persistent storage. See '
|
| 152 |
+
'https://huggingface.co/docs/hub/spaces-storage',
|
| 153 |
index=storage_options.index(hf_storage if hf_storage else 'None'),
|
| 154 |
)
|
| 155 |
|
|
|
|
| 226 |
'hf_dataset_name', None
|
| 227 |
)
|
| 228 |
if st.session_state.get('ds_loaded', False):
|
|
|
|
|
|
|
| 229 |
st.sidebar.header(
|
| 230 |
f'[{dataset_name}](https://huggingface.co/datasets/{dataset_name})',
|
| 231 |
divider='rainbow',
|
| 232 |
anchor=False,
|
| 233 |
+
help='Dataset information from HuggingFace datasets.',
|
| 234 |
)
|
| 235 |
|
| 236 |
st.sidebar.write(st.session_state.get('ds_description', None))
|