-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use entry point to expose methods alias.
- Loading branch information
1 parent
4e881be
commit faa28b8
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) 2024 ScicatProject contributors (https://github.com/ScicatProject) | ||
from importlib.metadata import entry_points | ||
from typing import Callable | ||
|
||
|
||
def load_metadata_extractors(extractor_name: str) -> Callable: | ||
"""Load metadata extractors from the entry points.""" | ||
|
||
return entry_points(group="scicat_ingestor.metadata_extractor")[ | ||
extractor_name | ||
].load() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
|
||
from scicat_metadata import load_metadata_extractors | ||
|
||
|
||
@pytest.mark.parametrize( | ||
["extractor_name", "expected_result"], [("max", 5), ("min", 1), ("mean", 3)] | ||
) | ||
def test_metadata_extractor(extractor_name: str, expected_result: int): | ||
"""Test if the metadata extractor can be loaded.""" | ||
test_data = [1, 2, 3, 4, 5] | ||
assert load_metadata_extractors(extractor_name)(test_data) == expected_result |