ocean-data-factory-sweden / kso

Notebooks to upload/download marine footage, connect to a citizen science project, train machine learning models and publish marine biological observations.
GNU General Public License v3.0
4 stars 12 forks source link

Tutorial 8 Sampling and processing zooniverse classifications error at pp.process_zoo_classifications() #239

Closed Bergylta closed 10 months ago

Bergylta commented 10 months ago

ts()`.

🐛 Bug

A clear and concise description of what the bug is.

To Reproduce (REQUIRED)

Project: Koster Seafloor observatory choice: "No, just download the last available information" Input:

pp.process_zoo_classifications()

Output:

NameError                                 Traceback (most recent call last)
Cell In[9], line 1
----> 1 pp.process_zoo_classifications()

File /usr/src/app/kso/kso_utils/kso_utils/project.py:777, in ProjectProcessor.process_zoo_classifications(self, test)
    773     workflow_checks = self.workflow_widget.checks
    775 # Retrieve a subset of the subjects from the workflows of interest and
    776 # populate the sql subjects table
--> 777 zoo_utils.sample_subjects_from_workflows(
    778     project=self.project,
    779     server_connection=self.server_connection,
    780     db_connection=self.db_connection,
    781     workflow_widget_checks=workflow_checks,
    782     workflows_df=self.zoo_info["workflows"],
    783     subjects_df=self.zoo_info["subjects"],
    784 )
    786 # Make sure all the classifications have existing subjects,
    787 # Flatten the classifications provided the cit. scientists
    788 self.processed_zoo_classifications = zoo_utils.process_zoo_classifications(
    789     project=self.project,
    790     db_connection=self.db_connection,
   (...)
    793     subject_type=workflow_checks["Subject type: #0"],
    794 )

File /usr/src/app/kso/kso_utils/kso_utils/zooniverse_utils.py:1265, in sample_subjects_from_workflows(project, server_connection, db_connection, workflow_widget_checks, workflows_df, subjects_df)
   1261 drop_table(conn=db_connection, table_name="subjects")
   1263 if len(subjects_series) > 0:
   1264     # Fill or re-fill subjects table
-> 1265     populate_subjects(project, server_connection, db_connection, subjects_series)
   1266 else:
   1267     logging.error("No subjects to populate database from the workflows selected.")

File /usr/src/app/kso/kso_utils/kso_utils/zooniverse_utils.py:1048, in populate_subjects(project, server_connection, db_connection, subjects)
   1045 else:
   1046     from kso_utils.koster_utils import process_koster_subjects
-> 1048     subjects = process_koster_subjects(subjects, db_connection)
   1049     # Fix weird bug where Subject_type is used instead of subject_type for the column name for some clips
   1050 #     if "Subject_type" in subjects.columns:
   1051 #         subjects["subject_type"] = subjects[
   (...)
   1077 
   1078 # Check if the Zooniverse project is the Spyfish
   1079 if project.Project_name == "Spyfish_Aotearoa":

File /usr/src/app/kso/kso_utils/kso_utils/koster_utils.py:288, in process_koster_subjects(subjects, conn)
    284 auto_subjects_df = auto_subjects(subjects, auto_date=auto_date)
    286 ## Update subjects manually uploaded
    287 # Select manually uploaded subjects
--> 288 manual_subjects_df = manual_subjects(
    289     subjects, manual_date=manual_date, auto_date=auto_date
    290 )
    292 # Include movie_ids to the metadata
    293 manual_subjects_df = get_movies_id(manual_subjects_df, conn=conn)

File /usr/src/app/kso/kso_utils/kso_utils/koster_utils.py:102, in manual_subjects(subjects_df, manual_date, auto_date)
     99 man_clips_df["subject_type"] = "clip"
    101 # Extract metadata from manually uploaded clips
--> 102 man_clips_df, man_clips_meta = extract_metadata(man_clips_df)
    104 # Process the metadata of manually uploaded clips
    105 man_clips_meta = process_manual_clips(man_clips_meta)

NameError: name 'extract_metadata' is not defined

Expected behavior

Zooniverse classification from workflow of interest should be visibla.

Environment

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

jannesgg commented 10 months ago

Fixed by https://github.com/ocean-data-factory-sweden/kso-utils/commit/d0002d91f4f208ede6a57bcc46a41b5fcfa89797