Skip to content

Commit 2803a9d

Browse files
authored
Fix usage matching (#18)
* Fix usage matching Fix linting * Attempt to fix test case * Fix Python version used in CI Test Python 3.13
1 parent 99fda7a commit 2803a9d

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ jobs:
3636
runs-on: ubuntu-latest
3737
timeout-minutes: 30
3838
strategy:
39-
max-parallel: 3
39+
max-parallel: 4
4040
matrix:
41-
python-version: ['3.10', '3.11', '3.12']
41+
python-version: ['3.10', '3.11', '3.12', '3.13']
4242

4343
steps:
4444

4545
- uses: actions/checkout@v4
4646

4747
- name: Set up Python ${{ matrix.python-version }}
4848
uses: actions/setup-python@v5
49+
with:
50+
python-version: ${{ matrix.python-version }}
4951

5052
- name: Install dependencies
5153
run: |

beam/__init__.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,16 @@ def extract(
181181
)
182182
extractor = json.loads(entry.read().decode("utf-8"))["data"]
183183

184-
match = find_matching_usage(
185-
usages=extractor["usage"],
186-
input_type=input_type,
187-
preferred_mode=preferred_mode,
188-
preferred_scope=preferred_scope,
189-
strict=True,
190-
)
184+
try:
185+
match = find_matching_usage(
186+
usages=extractor["usage"],
187+
input_type=input_type,
188+
preferred_mode=preferred_mode,
189+
preferred_scope=preferred_scope,
190+
strict=True,
191+
)
192+
except RuntimeError:
193+
match = None
191194
if match is not None:
192195
print(f"Found matching usage with extractor: {extractor['id']!r}")
193196
matching_definition = extractor
@@ -575,7 +578,12 @@ def parse_usage(
575578
preferred_mode: SupportedExecutionMethod = SupportedExecutionMethod.PYTHON,
576579
preferred_scope: SupportedUsageScope = SupportedUsageScope.DATA,
577580
) -> tuple[SupportedExecutionMethod, str, str]:
578-
usage = find_matching_usage(usages, input_type, preferred_mode, preferred_scope)
581+
try:
582+
usage = find_matching_usage(
583+
usages, input_type, preferred_mode, preferred_scope
584+
)
585+
except RuntimeError:
586+
usage = None
579587
if not usage:
580588
raise RuntimeError(
581589
f"No matching usage found for {input_type} with {preferred_mode} and {preferred_scope}"

tests/test_mpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_biologic_extract_from_url(tmp_path, test_mpr_urls):
6363
preferred_mode="python",
6464
install=(ind == 0),
6565
)
66-
assert data
66+
assert data is not None
6767

6868

6969
def test_biologic_extract_no_registry(test_mprs):

0 commit comments

Comments
 (0)