Merge branch 'main' into chore-aesthetics
Browse files- .pre-commit-config.yaml +21 -0
- app/config_utils.py +14 -0
- app/dead.py +5 -1
- app/dropdowns.py +3 -14
- app/followup_events.py +16 -0
- app/main.py +3 -0
- app/wounded.py +5 -2
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
repos:
|
2 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
+
rev: v4.4.0
|
4 |
+
hooks:
|
5 |
+
- id: check-case-conflict
|
6 |
+
- id: check-merge-conflict
|
7 |
+
- id: check-json
|
8 |
+
- id: check-toml
|
9 |
+
- id: check-xml
|
10 |
+
- id: check-yaml
|
11 |
+
- id: end-of-file-fixer
|
12 |
+
- id: trailing-whitespace
|
13 |
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
14 |
+
rev: v0.1.13
|
15 |
+
hooks:
|
16 |
+
- id: ruff
|
17 |
+
types_or: [ python, pyi, jupyter ]
|
18 |
+
args: [ --exit-zero ]
|
19 |
+
verbose: true
|
20 |
+
- id: ruff-format
|
21 |
+
types_or: [ python, pyi, jupyter ]
|
app/config_utils.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
|
4 |
+
def load_config(file_path):
|
5 |
+
with open(file_path) as f:
|
6 |
+
config = json.load(f)
|
7 |
+
return config
|
8 |
+
|
9 |
+
def get_custom_config_dropdowns(config_path):
|
10 |
+
path = os.getcwd()
|
11 |
+
dropdown_config_path = path + config_path
|
12 |
+
dropdown_config = load_config(dropdown_config_path)
|
13 |
+
return dropdown_config
|
14 |
+
|
app/dead.py
CHANGED
@@ -1,13 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
from top_section import create_top_section, create_dropdown
|
|
|
3 |
|
4 |
|
5 |
def show_section_dead(visible):
|
6 |
with gr.Column(visible=visible, elem_id="dead") as section_dead:
|
7 |
gr.Markdown("# Dead Animal")
|
8 |
-
gr.Markdown("Please describe the cause of death")
|
9 |
|
10 |
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible)
|
11 |
dropdown_row, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_dropdown(visible)
|
|
|
|
|
|
|
12 |
|
13 |
return section_dead, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
|
|
1 |
import gradio as gr
|
2 |
from top_section import create_top_section, create_dropdown
|
3 |
+
from followup_events import create_followup_section
|
4 |
|
5 |
|
6 |
def show_section_dead(visible):
|
7 |
with gr.Column(visible=visible, elem_id="dead") as section_dead:
|
8 |
gr.Markdown("# Dead Animal")
|
9 |
+
gr.Markdown("## Please describe the cause of death")
|
10 |
|
11 |
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible)
|
12 |
dropdown_row, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_dropdown(visible)
|
13 |
+
|
14 |
+
gr.Markdown("## Follow-up Events")
|
15 |
+
create_followup_section()
|
16 |
|
17 |
return section_dead, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
app/dropdowns.py
CHANGED
@@ -1,21 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
import os
|
4 |
|
5 |
-
def load_config(file_path):
|
6 |
-
with open(file_path) as f:
|
7 |
-
config = json.load(f)
|
8 |
-
return config
|
9 |
-
|
10 |
-
def get_custom_config_dropdowns():
|
11 |
-
path = os.getcwd()
|
12 |
-
dropdown_config_path = path + "/assets/dropdowns/dropdown_config.json"
|
13 |
-
dropdown_config = load_config(dropdown_config_path)
|
14 |
-
return dropdown_config
|
15 |
|
16 |
#--------------------------------------------------------- LEVEL 1 DROPDOWNS
|
17 |
def retrieve_config_options(label):
|
18 |
-
dropdown_config = get_custom_config_dropdowns()
|
19 |
options = list(dropdown_config[label].keys())
|
20 |
options = [option.title() for option in options]
|
21 |
return options
|
@@ -56,7 +45,7 @@ def get_options(value):
|
|
56 |
open_field = None
|
57 |
extras = None
|
58 |
extras_label = None
|
59 |
-
dropdown_config = get_custom_config_dropdowns()
|
60 |
for _, sub_dict in dropdown_config.items():
|
61 |
nested_dict = sub_dict.get(value)
|
62 |
if nested_dict is not None:
|
|
|
1 |
import gradio as gr
|
2 |
+
from config_utils import get_custom_config_dropdowns
|
|
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
#--------------------------------------------------------- LEVEL 1 DROPDOWNS
|
6 |
def retrieve_config_options(label):
|
7 |
+
dropdown_config = get_custom_config_dropdowns("/assets/dropdowns/dropdown_config.json")
|
8 |
options = list(dropdown_config[label].keys())
|
9 |
options = [option.title() for option in options]
|
10 |
return options
|
|
|
45 |
open_field = None
|
46 |
extras = None
|
47 |
extras_label = None
|
48 |
+
dropdown_config = get_custom_config_dropdowns("/assets/dropdowns/dropdown_config.json")
|
49 |
for _, sub_dict in dropdown_config.items():
|
50 |
nested_dict = sub_dict.get(value)
|
51 |
if nested_dict is not None:
|
app/followup_events.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from config_utils import get_custom_config_dropdowns
|
3 |
+
|
4 |
+
def create_followup_section():
|
5 |
+
followup_config = get_custom_config_dropdowns("/assets/dropdowns/followup_config.json")
|
6 |
+
followup_config = followup_config["Event follow-up"]
|
7 |
+
with gr.Row():
|
8 |
+
for key, val in followup_config.items():
|
9 |
+
followup_label = key
|
10 |
+
if "Options" in val.keys():
|
11 |
+
gr.Dropdown(choices=val["Options"], label=followup_label, visible=True)
|
12 |
+
with gr.Row():
|
13 |
+
for key, val in followup_config.items():
|
14 |
+
followup_label = key
|
15 |
+
if "Open" in val.keys():
|
16 |
+
gr.Textbox(label=followup_label, visible=True)
|
app/main.py
CHANGED
@@ -95,6 +95,9 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
95 |
|
96 |
dropdown_wounded.select(on_select, None, [dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
|
97 |
|
|
|
|
|
|
|
98 |
# ---------------------------------------------------------
|
99 |
#Submit Button
|
100 |
with gr.Column(scale=1):
|
|
|
95 |
|
96 |
dropdown_wounded.select(on_select, None, [dropdown_level2_wounded, openfield_level2_wounded, dropdown_extra_level2_wounded])
|
97 |
|
98 |
+
# ---------------------------------------------------------
|
99 |
+
#Follow up Events
|
100 |
+
|
101 |
# ---------------------------------------------------------
|
102 |
#Submit Button
|
103 |
with gr.Column(scale=1):
|
app/wounded.py
CHANGED
@@ -1,14 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
from top_section import create_top_section, create_dropdown
|
|
|
3 |
|
4 |
def show_section_wounded(visible):
|
5 |
-
#with gr.Tab("Wounded Information"):
|
6 |
with gr.Column(visible=visible, elem_id="wounded") as wounded_section:
|
7 |
gr.Markdown("# Wounded Animal")
|
8 |
-
gr.Markdown("Please describe the wound's cause.")
|
9 |
|
10 |
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible)
|
11 |
dropdown_row, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_dropdown(visible)
|
12 |
|
|
|
|
|
|
|
13 |
# Change variables and names
|
14 |
return wounded_section, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|
|
|
1 |
import gradio as gr
|
2 |
from top_section import create_top_section, create_dropdown
|
3 |
+
from followup_events import create_followup_section
|
4 |
|
5 |
def show_section_wounded(visible):
|
|
|
6 |
with gr.Column(visible=visible, elem_id="wounded") as wounded_section:
|
7 |
gr.Markdown("# Wounded Animal")
|
8 |
+
gr.Markdown("## Please describe the wound's cause.")
|
9 |
|
10 |
image_row, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause = create_top_section(visible)
|
11 |
dropdown_row, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2 = create_dropdown(visible)
|
12 |
|
13 |
+
gr.Markdown("## Follow-up Events")
|
14 |
+
create_followup_section()
|
15 |
+
|
16 |
# Change variables and names
|
17 |
return wounded_section, button_collision, button_deliberate_destruction, button_indirect_destruction, button_natural_cause, dropdown, dropdown_level2, openfield_level2, dropdown_extra_level2
|