Spaces:
Running
Running
rmm
commited on
Commit
·
3089ebb
1
Parent(s):
8083970
docs: added type hints to outstanding functions and docstrings
Browse files- src/input_handling.py +10 -1
- src/whale_viewer.py +5 -6
src/input_handling.py
CHANGED
@@ -27,7 +27,16 @@ allowed_image_types = ['jpg', 'jpeg', 'png', 'webp']
|
|
27 |
|
28 |
import random
|
29 |
import string
|
30 |
-
def generate_random_md5():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
# Generate a random string
|
32 |
random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=16))
|
33 |
# Encode the string and compute its MD5 hash
|
|
|
27 |
|
28 |
import random
|
29 |
import string
|
30 |
+
def generate_random_md5() -> str:
|
31 |
+
"""
|
32 |
+
Generates a random MD5 hash.
|
33 |
+
|
34 |
+
This function creates a random string of 16 alphanumeric characters,
|
35 |
+
encodes it, and then computes its MD5 hash.
|
36 |
+
|
37 |
+
Returns:
|
38 |
+
str: The MD5 hash of the generated random string.
|
39 |
+
"""
|
40 |
# Generate a random string
|
41 |
random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=16))
|
42 |
# Encode the string and compute its MD5 hash
|
src/whale_viewer.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from typing import List
|
|
|
2 |
|
3 |
from PIL import Image
|
4 |
import pandas as pd
|
@@ -117,22 +118,20 @@ def format_whale_name(whale_class:str) -> str:
|
|
117 |
return whale_name
|
118 |
|
119 |
|
120 |
-
def display_whale(whale_classes:List[str], i:int, viewcontainer=None):
|
121 |
"""
|
122 |
Display whale image and reference to the provided viewcontainer.
|
123 |
|
124 |
Args:
|
125 |
whale_classes (List[str]): A list of whale class names.
|
126 |
i (int): The index of the whale class to display.
|
127 |
-
viewcontainer: The container
|
128 |
-
not provided, use the current
|
129 |
-
'with `container`' syntax)
|
130 |
|
131 |
Returns:
|
132 |
None
|
133 |
|
134 |
-
TODO: how to find the object type of viewcontainer.? they are just "deltagenerators" but
|
135 |
-
we want the result of the generator.. In any case, it works ok with either call signature.
|
136 |
"""
|
137 |
import streamlit as st
|
138 |
if viewcontainer is None:
|
|
|
1 |
from typing import List
|
2 |
+
from streamlit.delta_generator import DeltaGenerator
|
3 |
|
4 |
from PIL import Image
|
5 |
import pandas as pd
|
|
|
118 |
return whale_name
|
119 |
|
120 |
|
121 |
+
def display_whale(whale_classes:List[str], i:int, viewcontainer:DeltaGenerator=None) -> None:
|
122 |
"""
|
123 |
Display whale image and reference to the provided viewcontainer.
|
124 |
|
125 |
Args:
|
126 |
whale_classes (List[str]): A list of whale class names.
|
127 |
i (int): The index of the whale class to display.
|
128 |
+
viewcontainer (streamlit.delta_generator.DeltaGenerator): The container
|
129 |
+
to display the whale information. If not provided, use the current
|
130 |
+
streamlit context (works via 'with `container`' syntax)
|
131 |
|
132 |
Returns:
|
133 |
None
|
134 |
|
|
|
|
|
135 |
"""
|
136 |
import streamlit as st
|
137 |
if viewcontainer is None:
|