Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename U19Etl #178

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ dynamic = ["version"]

dependencies = [
"aind-data-schema-models>=0.3.2",
"pydantic-settings>=2.0"
"pydantic-settings>=2.0",
"aind-data-schema==1.0.0"
]

[project.optional-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/aind_metadata_mapper/u19/procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def strings_to_dates(strings):
return [date1, date2]


class U19Etl(GenericEtl[JobSettings]):
class SmartSPIMSpecimenIngester(GenericEtl[JobSettings]):
"""U19 ETL class."""

# TODO: Deprecate this constructor. Use GenericEtl constructor instead
Expand Down Expand Up @@ -423,5 +423,5 @@ def extract_spec_procedures(self, subj_id, row): # noqa: C901
if __name__ == "__main__":
sys_args = sys.argv[1:]
main_job_settings = JobSettings.from_args(sys_args)
etl = U19Etl(job_settings=main_job_settings)
etl = SmartSPIMSpecimenIngester(job_settings=main_job_settings)
etl.run_job()
31 changes: 19 additions & 12 deletions tests/test_U19/test_procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from aind_metadata_mapper.u19.models import JobSettings
from aind_metadata_mapper.u19.procedures import (
U19Etl,
SmartSPIMSpecimenIngester,
get_dates,
strings_to_dates,
)
Expand Down Expand Up @@ -62,31 +62,35 @@ def setUpClass(self):
)

@patch(
"aind_metadata_mapper.u19.procedures.U19Etl.download_procedure_file"
"aind_metadata_mapper.u19."
"procedures.SmartSPIMSpecimenIngester."
"download_procedure_file"
)
def test_run_job(self, mock_download_procedure):
"""Test run_job method."""

with open(EXAMPLE_DOWNLOAD_PROCEDURE, "r") as f:
mock_download_procedure.return_value = json.load(f)

etl = U19Etl(self.example_job_settings)
etl = SmartSPIMSpecimenIngester(self.example_job_settings)
job_response = etl.run_job()

actual_output = json.loads(job_response.data)

self.assertEqual(self.example_output, actual_output)

@patch(
"aind_metadata_mapper.u19.procedures.U19Etl.download_procedure_file"
"aind_metadata_mapper.u19."
"procedures.SmartSPIMSpecimenIngester."
"download_procedure_file"
)
def test_extract(self, mock_download_procedure):
"""Test extract method."""

with open(EXAMPLE_DOWNLOAD_PROCEDURE, "r") as f:
mock_download_procedure.return_value = json.load(f)

etl = U19Etl(self.example_job_settings)
etl = SmartSPIMSpecimenIngester(self.example_job_settings)
extracted = etl._extract(self.example_job_settings.subject_to_ingest)

self.assertEqual(
Expand All @@ -97,7 +101,7 @@ def test_extract(self, mock_download_procedure):
def test_transform(self):
"""Test transform method."""

etl = U19Etl(self.example_job_settings)
etl = SmartSPIMSpecimenIngester(self.example_job_settings)
etl.load_specimen_procedure_file()

with open(EXAMPLE_DOWNLOAD_PROCEDURE, "r") as f:
Expand All @@ -116,15 +120,18 @@ def test_transform(self):
),
)

@patch("aind_metadata_mapper.u19.procedures.U19Etl._transform")
@patch(
"aind_metadata_mapper.u19.procedures."
"SmartSPIMSpecimenIngester._transform"
)
def test_load(self, mock_transform):
"""Test load method."""

mock_transform.return_value = construct_new_model(
self.example_output, Procedures, True
)

etl = U19Etl(self.example_job_settings)
etl = SmartSPIMSpecimenIngester(self.example_job_settings)
transformed = etl._transform(
self.example_job_settings.subject_to_ingest
)
Expand All @@ -140,7 +147,7 @@ def test_load(self, mock_transform):
def test_find_sheet_row(self):
"""Test find_sheet_row method."""

etl = U19Etl(self.example_job_settings)
etl = SmartSPIMSpecimenIngester(self.example_job_settings)
etl.load_specimen_procedure_file()
row = etl.find_sheet_row(self.example_job_settings.subject_to_ingest)

Expand All @@ -157,7 +164,7 @@ def test_download_procedure_file(self, mock_requests):
)
mock_requests.return_value.status_code = 200

etl = U19Etl(self.example_job_settings)
etl = SmartSPIMSpecimenIngester(self.example_job_settings)
response = etl.download_procedure_file(
self.example_job_settings.subject_to_ingest
)
Expand All @@ -170,7 +177,7 @@ def test_download_procedure_file(self, mock_requests):
def test_load_specimen_procedure_file(self):
"""Test load_specimen_procedure_file method."""

etl = U19Etl(self.example_job_settings)
etl = SmartSPIMSpecimenIngester(self.example_job_settings)
etl.load_specimen_procedure_file()

self.assertTrue(len(etl.tissue_sheets) == 2)
Expand All @@ -192,7 +199,7 @@ def test_strings_to_dates(self):
def test_extract_spec_procedures(self):
"""Test extract_spec_procedures method."""

etl = U19Etl(self.example_job_settings)
etl = SmartSPIMSpecimenIngester(self.example_job_settings)
etl.load_specimen_procedure_file()

row = etl.find_sheet_row(self.example_job_settings.subject_to_ingest)
Expand Down
22 changes: 11 additions & 11 deletions tests/test_open_ephys/test_utils/test_behavior_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def test_get_visual_stimuli_df(
expected_df = pd.DataFrame(expected_data, columns=expected_columns)

# Perform assertions
self.assertEquals(result_df["time"].all(), expected_df["time"].all())
self.assertEqual(result_df["time"].all(), expected_df["time"].all())

def test_get_image_names(self):
"""
Expand Down Expand Up @@ -870,7 +870,7 @@ def test_fingerprint_from_stimulus_file(self):
expected_df = pd.DataFrame(expected_data, columns=expected_columns)

# Assert that the result matches the expected DataFrame
self.assertEquals(
self.assertEqual(
expected_df["movie_frame_index"].values.tolist(),
result["movie_frame_index"].values.tolist(),
)
Expand Down Expand Up @@ -1036,7 +1036,7 @@ def test_from_stimulus_file(
expected_df = pd.DataFrame(expected_data, columns=expected_columns)

# Assert that the result matches the expected DataFrame
self.assertEquals(
self.assertEqual(
expected_df["start_time"].all(), result["start_time"].all()
)

Expand Down Expand Up @@ -1086,23 +1086,23 @@ def test_postprocess(self):

processed_presentations = pd.DataFrame(processed_presentations)
# Assert that the result matches the expected DataFrame
self.assertEquals(
self.assertEqual(
expected_df["duration"].all(),
processed_presentations["duration"].all(),
)
self.assertEquals(
self.assertEqual(
expected_df["start_time"].all(),
processed_presentations["start_time"].all(),
)
self.assertEquals(
self.assertEqual(
expected_df["image_name"].all(),
processed_presentations["image_name"].all(),
)
self.assertEquals(
self.assertEqual(
expected_df["omitted"].all(),
processed_presentations["omitted"].all(),
)
self.assertEquals(
self.assertEqual(
expected_df["boolean_col"].all(),
processed_presentations["boolean_col"].all(),
)
Expand Down Expand Up @@ -1130,7 +1130,7 @@ def test_check_for_errant_omitted_stimulus(self):
}
expected_df = pd.DataFrame(expected_data)
# Assert that the result matches the expected DataFrame
self.assertEquals(
self.assertEqual(
processed_df["omitted"].all(), expected_df["omitted"].all()
)

Expand Down Expand Up @@ -1200,7 +1200,7 @@ def test_get_spontaneous_stimulus(self):
expected_df = pd.DataFrame(expected_data)

# Assert that the result matches the expected DataFrame
self.assertEquals(
self.assertEqual(
processed_df["start_frame"].all(), expected_df["start_frame"].all()
)

Expand Down Expand Up @@ -1261,7 +1261,7 @@ def test_add_fingerprint_stimulus(self):
expected_df = pd.DataFrame(expected_data)

# Assert that the result matches the expected DataFrame
self.assertEquals(
self.assertEqual(
processed_df["start_frame"].all(), expected_df["start_frame"].all()
)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_open_ephys/test_utils/test_stim_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,19 @@ def mock_spontaneous_activity_tabler(stimulus_tables):
mock_stimulus_tabler,
mock_spontaneous_activity_tabler,
)
self.assertEquals(
self.assertEqual(
result_stim_table_full["start_time"].all(),
expected_stim_table_full["start_time"].all(),
)
self.assertEquals(
self.assertEqual(
result_stim_table_full["end_time"].all(),
expected_stim_table_full["end_time"].all(),
)
self.assertEquals(
self.assertEqual(
result_stim_table_full["stim_param"].all(),
expected_stim_table_full["stim_param"].all(),
)
self.assertEquals(
self.assertEqual(
result_stim_table_full["stim_block"].all(),
expected_stim_table_full["stim_block"].all(),
)
Expand Down
Loading