Skip to content

Commit

Permalink
fix tmp path factory
Browse files Browse the repository at this point in the history
  • Loading branch information
rwood-97 committed Sep 6, 2024
1 parent a9f54d9 commit 0e2bc76
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions test_text_spotting/test_deepsolo_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ADET_PATH = (
pathlib.Path("./DeepSolo/").resolve()
if os.getenv("GITHUB_ACTIONS") == "true"
else pathlib.Path(adet.__path__[0]).resolve().parent
else pathlib.Path(os.getenv("ADET_PATH")).resolve()
)


Expand All @@ -29,13 +29,14 @@ def sample_dir():


@pytest.fixture(scope="session")
def init_dataframes(sample_dir, tmp_path):
def init_dataframes(sample_dir, tmp_path_factory):
"""Initializes MapImages object (with metadata from csv and patches) and creates parent and patch dataframes.
Returns
-------
tuple
path to parent and patch dataframes
"""
tmp_path = tmp_path_factory.mktemp("patches")
maps = MapImages(f"{sample_dir}/mapreader_text.png")
maps.add_metadata(f"{sample_dir}/mapreader_text_metadata.csv")
maps.patchify_all(patch_size=800, path_save=tmp_path)
Expand Down
5 changes: 3 additions & 2 deletions test_text_spotting/test_dptext_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ADET_PATH = (
pathlib.Path("./DPText-DETR/").resolve()
if os.getenv("GITHUB_ACTIONS") == "true"
else pathlib.Path(adet.__path__[0]).resolve().parent
else pathlib.Path(os.getenv("ADET_PATH")).resolve()
)


Expand All @@ -29,13 +29,14 @@ def sample_dir():


@pytest.fixture(scope="session")
def init_dataframes(sample_dir, tmp_path):
def init_dataframes(sample_dir, tmp_path_factory):
"""Initializes MapImages object (with metadata from csv and patches) and creates parent and patch dataframes.
Returns
-------
tuple
path to parent and patch dataframes
"""
tmp_path = tmp_path_factory.mktemp("patches")
maps = MapImages(f"{sample_dir}/mapreader_text.png")
maps.add_metadata(f"{sample_dir}/mapreader_text_metadata.csv")
maps.patchify_all(patch_size=800, path_save=tmp_path)
Expand Down
9 changes: 5 additions & 4 deletions test_text_spotting/test_maptext_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ADET_PATH = (
pathlib.Path("./MapTextPipeline/").resolve()
if os.getenv("GITHUB_ACTIONS") == "true"
else pathlib.Path(adet.__path__[0]).resolve().parent
else pathlib.Path(os.getenv("ADET_PATH")).resolve()
)


Expand All @@ -29,13 +29,14 @@ def sample_dir():


@pytest.fixture(scope="session")
def init_dataframes(sample_dir, tmp_path):
def init_dataframes(sample_dir, tmp_path_factory):
"""Initializes MapImages object (with metadata from csv and patches) and creates parent and patch dataframes.
Returns
-------
tuple
path to parent and patch dataframes
"""
tmp_path = tmp_path_factory.mktemp("patches")
maps = MapImages(f"{sample_dir}/mapreader_text.png")
maps.add_metadata(f"{sample_dir}/mapreader_text_metadata.csv")
maps.patchify_all(patch_size=800, path_save=tmp_path)
Expand Down Expand Up @@ -143,7 +144,7 @@ def test_maptext_convert_to_parent(runner_run_all):
assert "mapreader_text.png" in out.keys()
assert isinstance(out["mapreader_text.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.patch_predictions, geo=False, parent=True)
out = runner._dict_to_dataframe(runner.parent_predictions, geo=False, parent=True)
assert isinstance(out, pd.DataFrame)
assert set(out.columns) == set(
["image_id", "patch_id", "geometry", "text", "score"]
Expand All @@ -159,7 +160,7 @@ def test_maptext_convert_to_parent_coords(runner_run_all):
assert "mapreader_text.png" in out.keys()
assert isinstance(out["mapreader_text.png"], list)
# dataframe
out = runner._dict_to_dataframe(runner.parent_predictions, geo=True, parent=True)
out = runner._dict_to_dataframe(runner.geo_predictions, geo=True, parent=True)
assert isinstance(out, gpd.GeoDataFrame)
assert set(out.columns) == set(
["image_id", "patch_id", "geometry", "crs", "text", "score"]
Expand Down

0 comments on commit 0e2bc76

Please sign in to comment.