From bdf057ea17a8df14206a8fccd852437f2eb3fbd6 Mon Sep 17 00:00:00 2001 From: egrace479 Date: Tue, 23 Apr 2024 17:58:04 -0400 Subject: [PATCH 01/13] Remove dependence on image filename (display based on urls only). --- components/query.py | 33 ++++++++++++--------------------- dashboard.py | 6 +----- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/components/query.py b/components/query.py index 8f0ab19..25c84c0 100644 --- a/components/query.py +++ b/components/query.py @@ -18,7 +18,7 @@ def get_data(df, mapping, features): df - DataFrame of the data to visualize. mapping - Boolean. True when lat/lon are given in dataset. features - List of features (columns) included in the DataFrame. This is a subset of the suggested columns: - 'Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', 'Lon', 'File_url', 'Image_filename' + 'Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', 'Lon', 'File_url' Returns: -------- @@ -109,28 +109,20 @@ def get_images(df, subspecies, view, sex, hybrid, num_images): -------- Imgs - List of html image elements with `src` element pointing to paths for the requested number of images matching given parameters. Returns html header4 "No Such Images. Please make another selection." if no images matching parameters exist. - Returns html header4 indicating number of matching entries without filename or filepath. + Returns html header4 indicating number of matching entries without filepath(s). ''' try: - filenames, filepaths = get_filenames(df, subspecies, view, sex, hybrid, num_images) + filepaths = get_filenames(df, subspecies, view, sex, hybrid, num_images) except ValueError as e: return html.H4(str(e) + " Please make another selection.", style = PRINT_STYLE) - Imgs = [] - for i in range(len(filenames)): - if filenames[i] in filepaths[i]: - image_path = filepaths[i] - else: - if filepaths[i][-1] == '/': - image_path = filepaths[i] + filenames[i] - else: - image_path = filepaths[i] + '/' + filenames[i] - Imgs.append(html.Img(src = image_path, style = IMG_STYLE)) + Imgs = [html.Img(src = filepaths[i], style = IMG_STYLE) for i in range(len(filepaths))] + return Imgs def get_filenames(df, subspecies, view, sex, hybrid, num_images): ''' - Funtion to randomly select the given number of filenames for images adhering to specified filters. + Funtion to randomly select the given number of filepaths (file urls) for images adhering to specified filters. Raises ValueError indicating no such images if none match the user selections. Parameters: @@ -144,7 +136,6 @@ def get_filenames(df, subspecies, view, sex, hybrid, num_images): Returns: -------- - filenames - List of filenames meeting specified conditions (the lesser of the requested amount or number available). filepaths - List of filepaths (URLs) corresponding to the selected filenames. ''' @@ -161,8 +152,7 @@ def get_filenames(df, subspecies, view, sex, hybrid, num_images): df_sub = df_sub.loc[df_sub.Hybrid_stat.isin(hybrid)] num_entries = len(df_sub) - # Filter out any entries that have missing filenames or URLs: - df_sub = df_sub.loc[df_sub.Image_filename != 'unknown'] + # Filter out any entries that have missing URLs: df_sub = df_sub.loc[df_sub.File_url != 'unknown'] max_imgs = len(df_sub) missing_vals = num_entries - max_imgs @@ -172,12 +162,13 @@ def get_filenames(df, subspecies, view, sex, hybrid, num_images): else: num = min(num_images, max_imgs) df_filtered = df_sub.sample(num) - filenames = df_filtered.Image_filename.astype('string').values filepaths = df_filtered.File_url.astype('string').values - #return list of filenames for min(user-selected, available) images randomly selected images from the filtered dataset - return list(filenames), list(filepaths) + #return list of filepaths for min(user-selected, available) images randomly selected images from the filtered dataset + return list(filepaths) # If there aren't any images to display, check if there are no such entries or just missing information. elif missing_vals == 0: + # No images & no matching records raise ValueError("No Such Images.") else: - raise ValueError("No Such Images. Unknown filename(s) or path(s).") + # There are records matching, but not able to display images for them + raise ValueError(f"No Such Images to display; {missing_vals} record(s) with unknown filepath(s) match this selection.") diff --git a/dashboard.py b/dashboard.py index 7e00ce1..09a5acf 100644 --- a/dashboard.py +++ b/dashboard.py @@ -81,7 +81,7 @@ def parse_contents(contents, filename): # If no image urls, disable sample image options mapping = True img_urls = True - features = ['Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', 'Lon', 'File_url', 'Image_filename'] + features = ['Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', 'Lon', 'File_url'] included_features = [] df.columns = df.columns.str.capitalize() for feature in features: @@ -97,10 +97,6 @@ def parse_contents(contents, filename): mapping = False elif feature == 'File_url': img_urls = False - elif feature == 'Image_filename': - # If 'Image_filename' missing, return missing column if 'file_url' is included. - if img_urls: - return json.dumps({'error': {'feature': feature}}) else: return json.dumps({'error': {'feature': feature}}) else: From 370d2e86f52c3b4b68fd7d15a28fc0a09a6b10f2 Mon Sep 17 00:00:00 2001 From: egrace479 Date: Wed, 24 Apr 2024 16:46:04 -0400 Subject: [PATCH 02/13] Update documentation to reflect removal of Image_filename requirement. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0e12781..75bf801 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Dashboard Prototype Prototype data dashboard using the [Cuthill Gold Standard Dataset](https://huggingface.co/datasets/imageomics/Curated_GoldStandard_Hoyal_Cuthill), which was processed from Cuthill, et. al. (original dataset available at [doi:10.5061/dryad.2hp1978](https://doi.org/10.5061/dryad.2hp1978)). Test datasets (the processed version of Cuthill's data with and without filepath URLs) are available in [test_data](./test_data). +This dashboard focuses on images labeled at the species and subspecies level as described in a CSV. ## How it works -For full dashboard functionality, upload a CSV or XLS file with the following columns: -- `Image_filename`*: Filename of each image, must be unique. **Note:** Images should be in PNG or JPEG format, TIFF may fail to render in the sample image display. +For full dashboard functionality, upload a CSV or XLS file with the following columns: - `Species`: Species of each sample. - `Subspecies`: Subspecies of each sample. - `View`: View of the sample (eg., 'ventral' or 'dorsal' for butterflies). @@ -13,12 +13,12 @@ For full dashboard functionality, upload a CSV or XLS file with the following co - `hybrid_stat`: Hybrid status of each sample (eg., 'valid_subspecies', 'subspecies_synonym', or 'unknown'). - `lat`*: Latitude at which image was taken or specimen was collected: number in [-90,90]. - `lon`*: Longitude at which image was taken or specimen was collected: number in [-180,180]. `long` will also be accepted. -- `file_url`*: URL to access file. +- `file_url`*: URL to access file. **Note:** Images should be in PNG or JPEG format, TIFF may fail to render in the sample image display. ***Note:** - Column names are **not** case-sensitive. - `lat` and `lon` columns are not required to utilize the dashboard, but there will be no map view if they are not included. Blank (or null) entries are recorded as `unknown`, and thus excluded from map view. -- `Image_filename` and `file_url` are not required, but there will be no sample images option if either one is not included. +- `file_url` is not required, but there will be no sample images option if it is not included. - `locality` may be provided, otherwise it will take on the value `lat|lon` or `unknown` if these are not provided. ## Running Dashboard From c125f763c1e78980b6cead3d9c04949a5dc32588 Mon Sep 17 00:00:00 2001 From: egrace479 Date: Wed, 24 Apr 2024 17:53:10 -0400 Subject: [PATCH 03/13] Update tests to reflect removal of dependence on image_filename --- tests/components/test_graphs.py | 2 +- tests/components/test_query.py | 58 ++++++++++++--------------------- tests/test_filters.py | 6 ++-- 3 files changed, 24 insertions(+), 42 deletions(-) diff --git a/tests/components/test_graphs.py b/tests/components/test_graphs.py index 1f2d4bf..2871c9f 100644 --- a/tests/components/test_graphs.py +++ b/tests/components/test_graphs.py @@ -6,7 +6,7 @@ df = pd.read_csv("test_data/HCGSD_full_testNA.csv") # Update columns since not running through parse df.columns = df.columns.str.capitalize() -included_features = ['Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', 'Lon', 'File_url', 'Image_filename'] +included_features = ['Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', 'Lon', 'File_url'] processed_df, cat_list = get_data(df, True, included_features) def test_make_hist_plot(): diff --git a/tests/components/test_query.py b/tests/components/test_query.py index 7be5180..5353beb 100644 --- a/tests/components/test_query.py +++ b/tests/components/test_query.py @@ -57,30 +57,21 @@ def test_get_filenames(self): BASE_URL_V = "https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/" BASE_URL_D = "https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/" data = { - 'Species': ['melpomene', 'melpomene', 'erato', 'melpomene', 'erato', 'species3', 'species3'], - 'Subspecies': ['schunkei', 'nanna', 'erato', 'rosina_N', 'guarica', 'subspecies6', 'subspecies6'], - 'View': ['ventral', 'ventral', 'ventral', 'dorsal', 'dorsal', 'ventral', 'dorsal'], - 'Sex': ['male', 'female', 'female', 'male', 'female', 'male', 'female'], + 'Species': ['melpomene', 'melpomene', 'erato', 'melpomene', 'erato', 'species3'], + 'Subspecies': ['schunkei', 'nanna', 'erato', 'rosina_N', 'guarica', 'subspecies6'], + 'View': ['ventral', 'ventral', 'ventral', 'dorsal', 'dorsal', 'ventral'], + 'Sex': ['male', 'female', 'female', 'male', 'female', 'male'], 'Hybrid_stat': ['subspecies synonym', 'valid subspecies', 'subspecies synonym', 'valid subspecies', 'valid subspecies', - 'valid subspecies', 'subspecies synonym'], - 'Image_filename': ['10428251_V_lowres.png', - '10428328_V_lowres.png', - '10428723_V_lowres.png', - '10427968_D_lowres.png', - '10428804_D_lowres.png', - 'unknown', - '10428723_V_lowres.png'], - 'File_url': [BASE_URL_V, - BASE_URL_V, - BASE_URL_V, - BASE_URL_D, - BASE_URL_D, - BASE_URL_V, + 'File_url': [BASE_URL_V + '10428251_V_lowres.png', + BASE_URL_V + '10428328_V_lowres.png', + BASE_URL_V + '10428723_V_lowres.png', + BASE_URL_D + '10427968_D_lowres.png', + BASE_URL_D + '10428804_D_lowres.png', 'unknown'] } df = pd.DataFrame(data = data) @@ -109,35 +100,26 @@ def test_get_filenames(self): ['valid subspecies', 'subspecies synonym'] ] test_nums = [2, 1, None, 1, 3] - test_images = ['10428251_V_lowres.png', - '10428804_D_lowres.png', - '10428723_V_lowres.png', - '10428804_D_lowres.png', - ['10428251_V_lowres.png', '10428328_V_lowres.png', '10427968_D_lowres.png'] - ] - test_paths = [BASE_URL_V, - BASE_URL_D, - BASE_URL_V, - BASE_URL_D, - [BASE_URL_V, - BASE_URL_V, - BASE_URL_D + test_paths = [BASE_URL_V + '10428251_V_lowres.png', + BASE_URL_D + '10428804_D_lowres.png', + BASE_URL_V + '10428723_V_lowres.png', + BASE_URL_D + '10428804_D_lowres.png', + [BASE_URL_V + '10428251_V_lowres.png', + BASE_URL_V + '10428328_V_lowres.png', + BASE_URL_D + '10427968_D_lowres.png' ]] # Test for proper filenames and filepaths for i in range(0, 4): - result, paths = get_filenames(df, test_subspecies[i], test_view[i], test_sex[i], test_hybrid[i], test_nums[i]) - self.assertEqual(result, [test_images[i]]) + paths = get_filenames(df, test_subspecies[i], test_view[i], test_sex[i], test_hybrid[i], test_nums[i]) self.assertEqual(paths, [test_paths[i]]) - result, paths = get_filenames(df, test_subspecies[4], test_view[4], test_sex[4], test_hybrid[4], test_nums[4]) + paths = get_filenames(df, test_subspecies[4], test_view[4], test_sex[4], test_hybrid[4], test_nums[4]) #check lists have same elements - self.assertCountEqual(result, test_images[4]) self.assertCountEqual(paths, test_paths[4]) @patch('components.query.get_filenames') def test_get_images(self, mock_filenames): - filenames = ['filename' + str(i) for i in range(5)] filepaths = ['filepath' + str(i) for i in range(5)] - mock_filenames.return_value = filenames, filepaths + mock_filenames.return_value = filepaths result = get_images(df = None, subspecies = None, view = None, sex = None, hybrid = None, num_images = 5) self.assertEqual(len(result), 5) - self.assertEqual([result[i].src for i in range(5)], [filepaths[i] + '/' + filenames[i] for i in range(5)]) + self.assertEqual([result[i].src for i in range(5)], [filepaths[i] for i in range(5)]) diff --git a/tests/test_filters.py b/tests/test_filters.py index b308ff2..80f993e 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -21,7 +21,7 @@ def generate_mock_upload(filepath): return contents ALL_COLUMNS = ['Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', 'Lon', - 'File_url', 'Image_filename', 'Locality', 'lat-lon', + 'File_url', 'Locality', 'lat-lon', 'Samples_at_locality', 'Species_at_locality', 'Subspecies_at_locality'] # Define Test Cases @@ -46,7 +46,7 @@ def generate_mock_upload(filepath): "filepath": "test_data/HCGSD_testNA.csv", "filename": "HCGSD_testNA.csv", "expected_columns": ['Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', 'Lon', - 'Image_filename', 'Locality', 'lat-lon', + 'Locality', 'lat-lon', 'Samples_at_locality', 'Species_at_locality', 'Subspecies_at_locality'], "expected_mapping": True, "expected_images": False @@ -55,7 +55,7 @@ def generate_mock_upload(filepath): "filepath": "test_data/HCGSD_test_nolon.csv", "filename": "HCGSD_test_nolon.csv", "expected_columns": ['Species', 'Subspecies', 'View', 'Sex', 'Hybrid_stat', 'Lat', - 'File_url', 'Image_filename', 'Locality'], + 'File_url', 'Locality'], "expected_mapping": False, "expected_images": True }, From 227ed89767e623ddf7295e2bbd36ec247261fa27 Mon Sep 17 00:00:00 2001 From: egrace479 Date: Wed, 24 Apr 2024 17:55:05 -0400 Subject: [PATCH 04/13] Update test files (url col) to reflect removal of dependence on image_filename --- test_data/HCGSD_full_testNA.csv | 22 +++++++++++----------- test_data/HCGSD_test_latLonOOB.csv | 22 +++++++++++----------- test_data/HCGSD_test_latLong.csv | 22 +++++++++++----------- test_data/HCGSD_test_nolon.csv | 22 +++++++++++----------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/test_data/HCGSD_full_testNA.csv b/test_data/HCGSD_full_testNA.csv index 1abfa91..9560ea7 100644 --- a/test_data/HCGSD_full_testNA.csv +++ b/test_data/HCGSD_full_testNA.csv @@ -1,11 +1,11 @@ -NHM_Specimen,Image_filename,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,lon,speciesdesig,file_url -10429021,10429021_V_lowres.png,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,-77.75,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428972,10428972_V_lowres.png,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,-96.98333333,e. petiverana, -10429172,,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,,-84.68333333,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428595,10428595_D_lowres.png,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,-58.98333333,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ -10428140,10428140_V_lowres.png,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428250,10428250_V_lowres.png,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,-70.95,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10427979,,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ -10428803,10428803_D_lowres.png,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica, -10428169,10428169_V_lowres.png,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428321,10428321_D_lowres.png,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ \ No newline at end of file +NHM_Specimen,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,lon,speciesdesig,file_url +10429021,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,-77.75,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10429021_V_lowres.png +10428972,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,-96.98333333,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428972_V_lowres.png +10429172,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,92,-84.68333333,e. petiverana, +10428595,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,-58.98333333,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428595_D_lowres.png +10428140,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,-740,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428140_V_lowres.png +10428250,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,-70.95,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428250_V_lowres.png +10427979,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina, +10428803,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428803_D_lowres.png +10428169,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,730,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428169_V_lowres.png +10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png \ No newline at end of file diff --git a/test_data/HCGSD_test_latLonOOB.csv b/test_data/HCGSD_test_latLonOOB.csv index 9cb0a65..9560ea7 100644 --- a/test_data/HCGSD_test_latLonOOB.csv +++ b/test_data/HCGSD_test_latLonOOB.csv @@ -1,11 +1,11 @@ -NHM_Specimen,Image_filename,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,lon,speciesdesig,file_url -10429021,10429021_V_lowres.png,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,-77.75,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428972,10428972_V_lowres.png,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,-96.98333333,e. petiverana, -10429172,,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,92,-84.68333333,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428595,10428595_D_lowres.png,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,-58.98333333,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ -10428140,10428140_V_lowres.png,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,-740,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428250,10428250_V_lowres.png,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,-70.95,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10427979,,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ -10428803,10428803_D_lowres.png,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica, -10428169,10428169_V_lowres.png,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,730,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428321,10428321_D_lowres.png,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ \ No newline at end of file +NHM_Specimen,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,lon,speciesdesig,file_url +10429021,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,-77.75,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10429021_V_lowres.png +10428972,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,-96.98333333,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428972_V_lowres.png +10429172,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,92,-84.68333333,e. petiverana, +10428595,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,-58.98333333,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428595_D_lowres.png +10428140,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,-740,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428140_V_lowres.png +10428250,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,-70.95,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428250_V_lowres.png +10427979,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina, +10428803,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428803_D_lowres.png +10428169,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,730,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428169_V_lowres.png +10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png \ No newline at end of file diff --git a/test_data/HCGSD_test_latLong.csv b/test_data/HCGSD_test_latLong.csv index bf88cbc..eff8473 100644 --- a/test_data/HCGSD_test_latLong.csv +++ b/test_data/HCGSD_test_latLong.csv @@ -1,11 +1,11 @@ -NHM_Specimen,Image_filename,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,long,speciesdesig,file_url -10429021,10429021_V_lowres.png,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,-77.75,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428972,10428972_V_lowres.png,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,-96.98333333,e. petiverana, -10429172,,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,89,-84.68333333,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428595,10428595_D_lowres.png,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,-58.98333333,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ -10428140,10428140_V_lowres.png,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,-74,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428250,10428250_V_lowres.png,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,-70.95,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10427979,,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ -10428803,10428803_D_lowres.png,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica, -10428169,10428169_V_lowres.png,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,73,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428321,10428321_D_lowres.png,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ \ No newline at end of file +NHM_Specimen,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,long,speciesdesig,file_url +10429021,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,-77.75,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10429021_V_lowres.png +10428972,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,-96.98333333,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428972_V_lowres.png +10429172,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,89,-84.68333333,e. petiverana, +10428595,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,-58.98333333,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428595_D_lowres.png +10428140,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,-74,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428140_V_lowres.png +10428250,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,-70.95,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428250_V_lowres.png +10427979,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina, +10428803,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428803_D_lowres.png +10428169,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,73,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428169_V_lowres.png +10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png \ No newline at end of file diff --git a/test_data/HCGSD_test_nolon.csv b/test_data/HCGSD_test_nolon.csv index 206d575..e4a71fe 100644 --- a/test_data/HCGSD_test_nolon.csv +++ b/test_data/HCGSD_test_nolon.csv @@ -1,11 +1,11 @@ -NHM_Specimen,Image_filename,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,speciesdesig,file_url -10429021,10429021_V_lowres.png,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428972,10428972_V_lowres.png,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,e. petiverana, -10429172,,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428595,10428595_D_lowres.png,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ -10428140,10428140_V_lowres.png,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428250,10428250_V_lowres.png,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10427979,,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,m. rosina,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ -10428803,10428803_D_lowres.png,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,e. guarica, -10428169,10428169_V_lowres.png,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/ -10428321,10428321_D_lowres.png,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/ \ No newline at end of file +NHM_Specimen,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,in_reduced,locality,lat,speciesdesig,file_url +10429021,,erato,notabilis,,f._notabilis,,subspecies synonym,1,,-1.583333333,e. notabilis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10429021_V_lowres.png +10428972,ventral,erato,petiverana,male,petiverana,,valid subspecies,1,Songolica (= Zongolica) MEX VC,18.66666667,e. petiverana,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428972_V_lowres.png +10429172,ventral,,petiverana,male,petiverana,,valid subspecies,1,San Ramon NIC ZE,,e. petiverana, +10428595,dorsal,erato,phyllis,male,f._phyllis,,subspecies synonym,1,Resistencia ARG CH,-27.45,e. phyllis,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428595_D_lowres.png +10428140,ventral,,plesseni,male,plesseni,,valid subspecies,1,Banos ECD TU,-1.4,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428140_V_lowres.png +10428250,ventral,melpomene,,male,ab._rubra,,subspecies synonym,1,Caradoc (Hda) PER CU,-13.36666667,m. schunkei,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428250_V_lowres.png +10427979,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,m. rosina, +10428803,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,e. guarica,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428803_D_lowres.png +10428169,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428169_V_lowres.png +10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png \ No newline at end of file From bef9afbce48aa7e4d16fbbdbc481a1681666ab79 Mon Sep 17 00:00:00 2001 From: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:45:46 -0400 Subject: [PATCH 05/13] fix typo in function description Co-authored-by: John Bradley --- components/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/query.py b/components/query.py index 25c84c0..32c3c48 100644 --- a/components/query.py +++ b/components/query.py @@ -122,7 +122,7 @@ def get_images(df, subspecies, view, sex, hybrid, num_images): def get_filenames(df, subspecies, view, sex, hybrid, num_images): ''' - Funtion to randomly select the given number of filepaths (file urls) for images adhering to specified filters. + Function to randomly select the given number of filepaths (file urls) for images adhering to specified filters. Raises ValueError indicating no such images if none match the user selections. Parameters: From 1128c13d9b735807f75f00837fe9fca4458d8b1e Mon Sep 17 00:00:00 2001 From: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:48:22 -0400 Subject: [PATCH 06/13] Apply suggestions from code review Add EOF newlines to CSVs Co-authored-by: Matt Thompson <31709066+thompsonmj@users.noreply.github.com> --- test_data/HCGSD_full_testNA.csv | 2 +- test_data/HCGSD_test_latLonOOB.csv | 2 +- test_data/HCGSD_test_latLong.csv | 2 +- test_data/HCGSD_test_nolon.csv | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test_data/HCGSD_full_testNA.csv b/test_data/HCGSD_full_testNA.csv index 9560ea7..1b441ff 100644 --- a/test_data/HCGSD_full_testNA.csv +++ b/test_data/HCGSD_full_testNA.csv @@ -8,4 +8,4 @@ NHM_Specimen,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,i 10427979,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina, 10428803,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428803_D_lowres.png 10428169,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,730,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428169_V_lowres.png -10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png \ No newline at end of file +10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png diff --git a/test_data/HCGSD_test_latLonOOB.csv b/test_data/HCGSD_test_latLonOOB.csv index 9560ea7..1b441ff 100644 --- a/test_data/HCGSD_test_latLonOOB.csv +++ b/test_data/HCGSD_test_latLonOOB.csv @@ -8,4 +8,4 @@ NHM_Specimen,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,i 10427979,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina, 10428803,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428803_D_lowres.png 10428169,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,730,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428169_V_lowres.png -10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png \ No newline at end of file +10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png diff --git a/test_data/HCGSD_test_latLong.csv b/test_data/HCGSD_test_latLong.csv index eff8473..7fb5dbe 100644 --- a/test_data/HCGSD_test_latLong.csv +++ b/test_data/HCGSD_test_latLong.csv @@ -8,4 +8,4 @@ NHM_Specimen,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,i 10427979,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,-83.63333333,m. rosina, 10428803,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,-74.36666667,e. guarica,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428803_D_lowres.png 10428169,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,73,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428169_V_lowres.png -10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png \ No newline at end of file +10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,-40.28333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png diff --git a/test_data/HCGSD_test_nolon.csv b/test_data/HCGSD_test_nolon.csv index e4a71fe..6e0fce5 100644 --- a/test_data/HCGSD_test_nolon.csv +++ b/test_data/HCGSD_test_nolon.csv @@ -8,4 +8,4 @@ NHM_Specimen,View,Species,Subspecies,Sex,addit_taxa_info,type_stat,hybrid_stat,i 10427979,dorsal,melpomene,rosina_S,male,rosina_S,,valid subspecies,1,Turrialba CRI CA,9.883333333,m. rosina, 10428803,dorsal,erato,guarica,female,guarica,,valid subspecies,1,Fusagasuga COL CN,4.35,e. guarica,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428803_D_lowres.png 10428169,ventral,melpomene,plesseni,male,f._pura,ST,subspecies synonym,1,Canelos ECD PA,-1.583333333,m. plesseni,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/ventral_images/10428169_V_lowres.png -10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png \ No newline at end of file +10428321,,melpomene,nanna,male,nanna,ST,valid subspecies,1,Espirito Santo BRA ES,-20.33333333,m. nanna,https://github.com/Imageomics/dashboard-prototype/raw/main/test_data/images/dorsal_images/10428321_D_lowres.png From 0cfc2e42a20299f543d8e6057cce9b991d1e2c03 Mon Sep 17 00:00:00 2001 From: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:31:57 -0400 Subject: [PATCH 07/13] Remove redundancy from function description Co-authored-by: Hilmar Lapp --- components/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/query.py b/components/query.py index 32c3c48..1f4cf79 100644 --- a/components/query.py +++ b/components/query.py @@ -122,7 +122,7 @@ def get_images(df, subspecies, view, sex, hybrid, num_images): def get_filenames(df, subspecies, view, sex, hybrid, num_images): ''' - Function to randomly select the given number of filepaths (file urls) for images adhering to specified filters. + Randomly selects the given number of filepaths (file urls) for images adhering to specified filters. Raises ValueError indicating no such images if none match the user selections. Parameters: From d9dd3c5a404d8f53ac83610c1518f2df0cb55fd3 Mon Sep 17 00:00:00 2001 From: egrace479 Date: Mon, 29 Apr 2024 13:15:51 -0400 Subject: [PATCH 08/13] Standardize function descriptions --- components/divs.py | 12 ++++++------ components/query.py | 6 +++--- dashboard.py | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/components/divs.py b/components/divs.py index e4e58e8..8c5602e 100644 --- a/components/divs.py +++ b/components/divs.py @@ -29,7 +29,7 @@ def get_hist_div(mapping): ''' - Function to generate the histogram options section of the dashboard, including button to select 'Map View'. + Generates the histogram options section of the dashboard, including button to select 'Map View'. Provides choice of variables for distribution and to color by, with options for order to sort x-axis. Parameters: @@ -93,7 +93,7 @@ def get_hist_div(mapping): def get_map_div(): ''' - Function to generate the mapping options section of the dashboard. + Generates the mapping options section of the dashboard. Provides choice of variables to color by and button to switch back to histogram ('Show Histogram'). Returns: @@ -152,8 +152,8 @@ def get_map_div(): def get_img_div(df, all_species, img_url): ''' - Function to generate the Image Sampling options section of the dashboard, including button to display images. - Provides empty list if no URLS are provided in the DataFrame for the entries. + Generates the Image Sampling options section of the dashboard, including button to display images. + Provides empty list if no URLs are provided in the DataFrame for the entries. Parameters: ----------- @@ -241,7 +241,7 @@ def get_img_div(df, all_species, img_url): def get_main_div(hist_div, img_div): ''' - Function to return main div based on upload of data. + Returns main div based on upload of data. Parameters: ----------- @@ -299,7 +299,7 @@ def get_main_div(hist_div, img_div): def get_error_div(error_dict): ''' - Function to return appropriate error message if there's a problem uploading the selected file. + Returns appropriate error message if there's a problem uploading the selected file. Parameters: ----------- diff --git a/components/query.py b/components/query.py index 1f4cf79..eb11f62 100644 --- a/components/query.py +++ b/components/query.py @@ -8,7 +8,7 @@ def get_data(df, mapping, features): ''' - Function to read in DataFrame and perform required manipulations: + Reads in DataFrame and performs required manipulations: - fill null values in required columns with 'unknown' - add 'lat-lon', `Samples_at_locality`, 'Species_at_locality', and 'Subspecies_at_locality' columns. - make list of categorical columns. @@ -68,7 +68,7 @@ def get_data(df, mapping, features): def get_species_options(df): ''' - Function to pull in DataFrame and produce a dictionary of species options (Melpomene, Erato, and Any) + Pulls in DataFrame and produces a dictionary of species options (Melpomene, Erato, and Any) Parameters: ----------- @@ -94,7 +94,7 @@ def get_species_options(df): def get_images(df, subspecies, view, sex, hybrid, num_images): ''' - Function to retrieve the user-selected number of images. + Retrieves the user-selected number of images. Parameters: ----------- diff --git a/dashboard.py b/dashboard.py index 09a5acf..f948e93 100644 --- a/dashboard.py +++ b/dashboard.py @@ -55,7 +55,7 @@ def parse_contents(contents, filename): ''' - Function to read uploaded data. + Reads uploaded data, checks that it meets requirements, and processes it. Returns processed data and available options in JSON. ''' if contents is None: raise PreventUpdate @@ -150,7 +150,7 @@ def update_output(contents, filename): def get_visuals(jsonified_data): ''' - Function that usese the processed and saved data to get the main div (histogram, pie chart, and image example options). + Fetches the main div (histogram, pie chart, and image example options) based on the processed and saved data. Returns error div if error occurs in upload or essential features are missing. ''' # load saved data @@ -177,7 +177,7 @@ def get_visuals(jsonified_data): def update_dist_view(n_clicks, children, jsonified_data): ''' - Function to update the upper left distribution options based on selected distribution chart (histogram or map). + Updates the upper left distribution options based on selected distribution chart (histogram or map). Activates on click to change, defaults to histogram view. Parameters: @@ -217,7 +217,7 @@ def update_dist_view(n_clicks, children, jsonified_data): def update_dist_plot(x_var, color_by, sort_by, btn, jsonified_data): ''' - Function to update distribution figure with either map or histogram based on selections. + Updates distribution figure with either map or histogram based on selections. Selection is based on current label of the button ('Map View' or 'Show Histogram'), which updates prior to graph. Parameters: @@ -281,7 +281,7 @@ def update_pie_plot(var, jsonified_data): def set_subspecies_options(selected_species, jsonified_data): ''' - Function to set subspecies options in dropdown based on user-selected species. + Sets subspecies options in dropdown based on user-selected species. Parameters: ----------- @@ -321,7 +321,7 @@ def set_subspecies_value(available_options): # Retrieve selected number of images def update_display(n_clicks, jsonified_data, subspecies, view, sex, hybrid, num_images): ''' - Function to retrieve the user-selected number of images adhering to their chosen parameters when the 'Display Images' button is pressed. + Retrieves the user-selected number of images adhering to their chosen parameters when the 'Display Images' button is pressed. Parameters: ----------- From 5232e668b41a5deb4e6daa271facff8a97fab22d Mon Sep 17 00:00:00 2001 From: egrace479 Date: Mon, 29 Apr 2024 17:17:50 -0400 Subject: [PATCH 09/13] Adjust species and subspecies option generation to fix image dropdown bug (#63) Also removes capitalization to ensure consistency with provided values. --- components/query.py | 18 ++++++++++-------- dashboard.py | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/components/query.py b/components/query.py index eb11f62..a336c44 100644 --- a/components/query.py +++ b/components/query.py @@ -68,7 +68,7 @@ def get_data(df, mapping, features): def get_species_options(df): ''' - Pulls in DataFrame and produces a dictionary of species options (Melpomene, Erato, and Any) + Pulls in DataFrame and produces a dictionary of species options (eg., melpomene, erato, and Any) Parameters: ----------- @@ -79,13 +79,13 @@ def get_species_options(df): all_species - Dictionary of all potential species options and their subspecies. ''' - species_list = list(df.Species.unique()) + species_list = list(df.Species.dropna().unique()) # drop nulls to avoid adding non-species (or subspecies below) all_species = {} for species in species_list: - subspecies_list = df.loc[df.Species == species, 'Subspecies'].unique() - subspecies_list = np.insert(subspecies_list, 0 , 'Any-' + species.capitalize()) - all_species[species.capitalize()] = list(subspecies_list) - all_subspecies = np.insert(df.Subspecies.unique(), 0, 'Any') + subspecies_list = df.loc[df.Species == species, 'Subspecies'].dropna().unique() + subspecies_list = np.insert(subspecies_list, 0 , 'Any-' + species) # need this to match as filled for img selection + all_species[species] = list(subspecies_list) + all_subspecies = np.insert(df.Subspecies.dropna().unique(), 0, 'Any') all_species['Any'] = list(all_subspecies) return all_species @@ -139,11 +139,13 @@ def get_filenames(df, subspecies, view, sex, hybrid, num_images): filepaths - List of filepaths (URLs) corresponding to the selected filenames. ''' - if 'Any' in subspecies and type(subspecies) == str: + if ('Any' in subspecies and type(subspecies) == str) or ('Any' in subspecies[0] and len(subspecies) == 1): + if type(subspecies) == list: + subspecies = subspecies[0] if subspecies == 'Any': df_sub = df.copy() else: - species = subspecies.split('-')[1].lower() + species = subspecies.split('-')[1] # should match case as filled df_sub = df.loc[df.Species == species].copy() else: df_sub = df.loc[df.Subspecies.isin(subspecies)].copy() diff --git a/dashboard.py b/dashboard.py index f948e93..fc2ab2e 100644 --- a/dashboard.py +++ b/dashboard.py @@ -116,10 +116,10 @@ def parse_contents(contents, filename): # get dataset-determined static data: # the dataframe and categorical features - processed for map view if mapping is True - # all possible species, subspecies + # all possible species, subspecies -- must run first to avoid adding "unknown" to lists # will likely include categorical options in later instance (sooner) + all_species = get_species_options(df) processed_df, cat_list = get_data(df, mapping, included_features) - all_species = get_species_options(processed_df) # save data to dictionary to save as json data = { 'processed_df': processed_df.to_json(date_format = 'iso', orient = 'split'), From 7696d0d94bc895cb106782386d5daeaeb641bcce Mon Sep 17 00:00:00 2001 From: egrace479 Date: Mon, 29 Apr 2024 17:19:08 -0400 Subject: [PATCH 10/13] Update tests for get species options and filenames functions accordingly --- tests/components/test_query.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/components/test_query.py b/tests/components/test_query.py index 5353beb..477b7d1 100644 --- a/tests/components/test_query.py +++ b/tests/components/test_query.py @@ -7,15 +7,15 @@ class TestQuery(unittest.TestCase): def test_get_species_options(self): data = { - 'Species': ['melpomene', 'erato', 'metharme'], + 'Species': ['Melpomene', 'erato', 'metharme'], 'Subspecies': ['subspecies1', 'subspecies2', 'subspecies3'] } df = pd.DataFrame(data=data) result = get_species_options(df) - self.assertEqual(result.keys(), set(["Melpomene", "Erato", "Metharme", "Any"])) + self.assertEqual(result.keys(), set(["Melpomene", "erato", "metharme", "Any"])) self.assertEqual(result["Melpomene"], ['Any-Melpomene', 'subspecies1']) - self.assertEqual(result["Erato"],['Any-Erato', 'subspecies2']) - self.assertEqual(result["Metharme"], ['Any-Metharme', 'subspecies3']) + self.assertEqual(result["erato"],['Any-erato', 'subspecies2']) + self.assertEqual(result["metharme"], ['Any-metharme', 'subspecies3']) self.assertEqual(result["Any"], ['Any', 'subspecies1', 'subspecies2', 'subspecies3']) @@ -75,9 +75,9 @@ def test_get_filenames(self): 'unknown'] } df = pd.DataFrame(data = data) - test_subspecies = ['Any-Melpomene', + test_subspecies = ['Any-melpomene', ['guarica'], - 'Any-Erato', + 'Any-erato', 'Any', ['schunkei', 'nanna', 'rosina_N'] ] From d093a47ea6500de823982c53c9415b2ad47f5bcd Mon Sep 17 00:00:00 2001 From: egrace479 Date: Thu, 16 May 2024 11:44:07 -0400 Subject: [PATCH 11/13] Update CITATION.cff for merge to main and release --- CITATION.cff | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 07d63c8..555bba1 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -18,14 +18,14 @@ authors: given-names: "Hilmar" orcid: "https://orcid.org/0000-0001-9107-0714" cff-version: 1.2.0 -date-released: "2024-03-08" +date-released: "2024-05-21" identifiers: - - description: "The GitHub release URL of tag 1.2.0." + - description: "The GitHub release URL of tag 1.3.0." type: url - value: "https://github.com/Imageomics/dashboard-prototype/releases/tag/v1.2.0" + value: "https://github.com/Imageomics/dashboard-prototype/releases/tag/v1.3.0" - description: "The GitHub URL of the commit tagged with 1.2.0." type: url - value: "https://github.com/Imageomics/dashboard-prototype/tree/d848922a28c37c03523413d5950823d13339aee1" + value: "https://github.com/Imageomics/dashboard-prototype/tree/d848922a28c37c03523413d5950823d13339aee1" #update on release keywords: - "EDA" - "data" From cc7b55a75571096b23631367f80e9013205f977d Mon Sep 17 00:00:00 2001 From: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com> Date: Tue, 21 May 2024 17:44:58 -0400 Subject: [PATCH 12/13] Update deploy-image.yml update actions to node.js 20 --- .github/workflows/deploy-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-image.yml b/.github/workflows/deploy-image.yml index b5f80ea..592dd9e 100644 --- a/.github/workflows/deploy-image.yml +++ b/.github/workflows/deploy-image.yml @@ -17,10 +17,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -28,7 +28,7 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | @@ -37,7 +37,7 @@ jobs: type=semver,pattern={{major}} - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v5 with: context: . push: true From 87934635f422e64cf7fd6e69584e96df3212022c Mon Sep 17 00:00:00 2001 From: Elizabeth Campolongo <38985481+egrace479@users.noreply.github.com> Date: Tue, 21 May 2024 17:47:52 -0400 Subject: [PATCH 13/13] Update run-tests.yml update to node.js 20 --- .github/workflows/run-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 712c7a2..8b1ef11 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,9 +10,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.11'