m7n commited on
Commit
3292cf5
·
1 Parent(s): d3f4baf

fixed requirements

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +27 -13
  3. requirements.txt +1 -1
.gitignore CHANGED
@@ -20,6 +20,7 @@ venv/
20
  env/
21
  .env/
22
  .venv/
 
23
 
24
  # Ignore IDE specific files
25
  .idea/
 
20
  env/
21
  .env/
22
  .venv/
23
+ openalex_env_map/
24
 
25
  # Ignore IDE specific files
26
  .idea/
app.py CHANGED
@@ -128,7 +128,14 @@ def predict(text_input, sample_size_slider, reduce_sample_checkbox, sample_reduc
128
  # Check if input is empty or whitespace
129
  print(f"Input: {text_input}")
130
  if not text_input or text_input.isspace():
131
- return "Error: Please enter a valid OpenAlex URL in the 'OpenAlex-search URL'-field", gr.DownloadButton(label=f"Download Interactive Visualization", value='html_file_path', visible=False)
 
 
 
 
 
 
 
132
 
133
 
134
  # Check if the input is a valid OpenAlex URL
@@ -235,6 +242,8 @@ def predict(text_input, sample_size_slider, reduce_sample_checkbox, sample_reduc
235
  # Create and save plot
236
  plot_start = time.time()
237
  progress(0.7, desc="Creating plot...")
 
 
238
 
239
 
240
  plot = datamapplot.create_interactive_plot(
@@ -251,16 +260,18 @@ def predict(text_input, sample_size_slider, reduce_sample_checkbox, sample_reduc
251
  text_outline_width=5,
252
  point_hover_color='#5e2784',
253
  point_radius_max_pixels=7,
254
- color_label_text=False,
 
255
  font_family="Roboto Condensed",
256
- font_weight=700,
257
  tooltip_font_weight=600,
258
  tooltip_font_family="Roboto Condensed",
259
  extra_point_data=extra_data,
260
  on_click="window.open(`{doi}`)",
261
  custom_css=DATAMAP_CUSTOM_CSS,
262
  initial_zoom_fraction=.8,
263
- enable_search=False
 
264
  )
265
 
266
  # Save plot
@@ -388,18 +399,21 @@ def predict(text_input, sample_size_slider, reduce_sample_checkbox, sample_reduc
388
  # Return iframe and download buttons with appropriate visibility
389
  return [
390
  iframe,
391
- gr.DownloadButton(label="Download Interactive Visualization", value=html_file_path, visible=True),
392
- gr.DownloadButton(label="Download CSV Data", value=csv_file_path, visible=download_csv_checkbox),
393
- gr.DownloadButton(label="Download Static Plot", value=png_file_path, visible=download_png_checkbox),
394
  gr.Button(visible=False) # Return hidden state for cancel button
395
  ]
396
 
397
 
398
  theme = gr.themes.Monochrome(
399
  font=[gr.themes.GoogleFont("Roboto Condensed"), "ui-sans-serif", "system-ui", "sans-serif"],
400
-
401
  text_size="lg",
402
-
 
 
 
 
403
  )
404
 
405
 
@@ -424,9 +438,9 @@ with gr.Blocks(theme=theme) as demo:
424
  cancel_btn = gr.Button("Cancel", visible=False, variant='secondary')
425
 
426
  # Create separate download buttons
427
- html_download = gr.DownloadButton("Download Interactive Visualization", visible=False)
428
- csv_download = gr.DownloadButton("Download CSV Data", visible=False)
429
- png_download = gr.DownloadButton("Download Static Plot", visible=False)
430
 
431
  text_input = gr.Textbox(label="OpenAlex-search URL",
432
  info="Enter the URL to an OpenAlex-search.")
@@ -483,7 +497,7 @@ with gr.Blocks(theme=theme) as demo:
483
  with gr.Column(scale=2):
484
  html = gr.HTML(
485
  value='<div style="width: 100%; height: 1000px; display: flex; justify-content: center; align-items: center; border: 1px solid #ccc; background-color: #f8f9fa;"><p style="font-size: 1.2em; color: #666;">The visualization map will appear here after running a query</p></div>',
486
- label="HTML preview",
487
  show_label=True
488
  )
489
  gr.Markdown("""
 
128
  # Check if input is empty or whitespace
129
  print(f"Input: {text_input}")
130
  if not text_input or text_input.isspace():
131
+ error_message = "Error: Please enter a valid OpenAlex URL in the 'OpenAlex-search URL'-field"
132
+ return [
133
+ error_message, # iframe HTML
134
+ gr.DownloadButton(label="Download Interactive Visualization", value='html_file_path', visible=False), # html download
135
+ gr.DownloadButton(label="Download CSV Data", value='csv_file_path', visible=False), # csv download
136
+ gr.DownloadButton(label="Download Static Plot", value='png_file_path', visible=False), # png download
137
+ gr.Button(visible=False) # cancel button state
138
+ ]
139
 
140
 
141
  # Check if the input is a valid OpenAlex URL
 
242
  # Create and save plot
243
  plot_start = time.time()
244
  progress(0.7, desc="Creating plot...")
245
+ # Create a solid black colormap
246
+ black_cmap = mcolors.LinearSegmentedColormap.from_list('black', ['#000000', '#000000'])
247
 
248
 
249
  plot = datamapplot.create_interactive_plot(
 
260
  text_outline_width=5,
261
  point_hover_color='#5e2784',
262
  point_radius_max_pixels=7,
263
+ cmap=black_cmap,
264
+ #color_label_text=False,
265
  font_family="Roboto Condensed",
266
+ font_weight=600,
267
  tooltip_font_weight=600,
268
  tooltip_font_family="Roboto Condensed",
269
  extra_point_data=extra_data,
270
  on_click="window.open(`{doi}`)",
271
  custom_css=DATAMAP_CUSTOM_CSS,
272
  initial_zoom_fraction=.8,
273
+ enable_search=False,
274
+ offline_mode=False
275
  )
276
 
277
  # Save plot
 
399
  # Return iframe and download buttons with appropriate visibility
400
  return [
401
  iframe,
402
+ gr.DownloadButton(label="Download Interactive Visualization", value=html_file_path, visible=True, variant='secondary'),
403
+ gr.DownloadButton(label="Download CSV Data", value=csv_file_path, visible=download_csv_checkbox, variant='secondary'),
404
+ gr.DownloadButton(label="Download Static Plot", value=png_file_path, visible=download_png_checkbox, variant='secondary'),
405
  gr.Button(visible=False) # Return hidden state for cancel button
406
  ]
407
 
408
 
409
  theme = gr.themes.Monochrome(
410
  font=[gr.themes.GoogleFont("Roboto Condensed"), "ui-sans-serif", "system-ui", "sans-serif"],
 
411
  text_size="lg",
412
+ ).set(
413
+ button_secondary_background_fill="white",
414
+ button_secondary_background_fill_hover="#f3f4f6",
415
+ button_secondary_border_color="black",
416
+ button_secondary_text_color="black",
417
  )
418
 
419
 
 
438
  cancel_btn = gr.Button("Cancel", visible=False, variant='secondary')
439
 
440
  # Create separate download buttons
441
+ html_download = gr.DownloadButton("Download Interactive Visualization", visible=False, variant='secondary')
442
+ csv_download = gr.DownloadButton("Download CSV Data", visible=False, variant='secondary')
443
+ png_download = gr.DownloadButton("Download Static Plot", visible=False, variant='secondary')
444
 
445
  text_input = gr.Textbox(label="OpenAlex-search URL",
446
  info="Enter the URL to an OpenAlex-search.")
 
497
  with gr.Column(scale=2):
498
  html = gr.HTML(
499
  value='<div style="width: 100%; height: 1000px; display: flex; justify-content: center; align-items: center; border: 1px solid #ccc; background-color: #f8f9fa;"><p style="font-size: 1.2em; color: #666;">The visualization map will appear here after running a query</p></div>',
500
+ label="",
501
  show_label=True
502
  )
503
  gr.Markdown("""
requirements.txt CHANGED
@@ -10,7 +10,7 @@ adapters
10
  torch
11
  tqdm
12
  pyarrow
13
- datamapplot==0.3.0
14
  numba==0.58.1
15
  umap-learn==0.5.7
16
  pynndescent==0.5.12
 
10
  torch
11
  tqdm
12
  pyarrow
13
+ datamapplot==0.5.0
14
  numba==0.58.1
15
  umap-learn==0.5.7
16
  pynndescent==0.5.12