From 2ef2c5a20a23361003368cf5ed0dc0c234e978e9 Mon Sep 17 00:00:00 2001 From: Caralyn Reisle Date: Tue, 6 Oct 2026 11:34:51 -0700 Subject: [PATCH 01/11] Update README.md Fix badge link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 192ab2a3..19032aea 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PORI Python Adaptor -![build](https://github.com/bcgsc/pori_python/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/bcgsc/pori_python/branch/master/graph/badge.svg)](https://codecov.io/gh/bcgsc/pori_python) +![build](https://github.com/bcgsc/pori_python/workflows/build/badge.svg) [![codecov](https://codecov.io/gh/bcgsc/pori_python/branch/main/graph/badge.svg)](https://codecov.io/gh/bcgsc/pori_python) This repository is part of the [Platform for Oncogenomic Reporting and Interpretation (PORI)](https://bcgsc.github.io/pori/). From 4909dce90d240b739537e14f7d009f0b33e9e6f2 Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 14:04:34 -0700 Subject: [PATCH 02/11] add option and upload test --- pori_python/ipr/main.py | 13 +++++++++++++ tests/test_ipr/test_upload.py | 24 +++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/pori_python/ipr/main.py b/pori_python/ipr/main.py index f4cafffa..05f1f21a 100644 --- a/pori_python/ipr/main.py +++ b/pori_python/ipr/main.py @@ -188,6 +188,12 @@ def command_interface() -> None: type=file_path, help='TSV without header, with two columns: transcripts and flags (comma-separated list of flags eg "MANE"). If header is included, it will be skipped. Matching uses direct string comparison, so transcript identifiers must match exactly, including version numbers (e.g., if input variants use ENST00000390477.1, this file must also use ENST00000390477.1, not ENST00000390477).', ) + parser.add_argument( + '--state', + required=False, + choices=['ready', 'nonproduction'], + help="Status to create the report with if not default (ready). If 'nonproduction', the report will be created with state='nonproduction' in the uploaded report content.", + ) args = parser.parse_args() with open(args.content, 'r') as fh: @@ -213,6 +219,7 @@ def command_interface() -> None: validate_json=args.validate_json, ignore_extra_fields=args.ignore_extra_fields, transcript_flags=args.transcript_flags, + state=args.state, ) @@ -350,6 +357,7 @@ def ipr_report( ignore_extra_fields: bool = False, tmb_high: float = TMB_SIGNATURE_HIGH_THRESHOLD, transcript_flags: str = '', + state: str = 'ready', ) -> dict: """Run the matching and create the report JSON for upload to IPR. @@ -380,6 +388,7 @@ def ipr_report( allow_partial_matches: allow matches to statements where not all conditions are satisfied tmb_high: mutation burden threshold/cutoff to qualify as 'high' transcript_flags: path to a tsv file with two columns (no header) of transcript identifiers and flags to be added to any observed variants with matching transcript in the report upload. If header is included, it will be skipped. Matching uses direct string comparison, so transcript identifiers must match exactly, including version numbers (e.g., if input variants use ENST00000390477.1, this file must also use ENST00000390477.1, not ENST00000390477). + state: the state to create the report with if not default ('ready'). If 'nonproduction', the report will be created with state='nonproduction' in the uploaded report content Returns: ipr_conn.upload_report return dictionary """ @@ -398,6 +407,10 @@ def ipr_report( else: logger.warning('No ipr_url given') + if state: + # copy so the caller's content is not mutated + content = {**content, 'state': state} + # Verify upload permission before doing any expensive processing if ipr_upload and ipr_conn: ipr_conn.check_upload_permission(content['project']) diff --git a/tests/test_ipr/test_upload.py b/tests/test_ipr/test_upload.py index 4445b9c4..5b7e6a93 100644 --- a/tests/test_ipr/test_upload.py +++ b/tests/test_ipr/test_upload.py @@ -1,12 +1,13 @@ import json import os -import pandas as pd -import pytest import sys import uuid -from typing import Generator +from collections.abc import Generator from unittest.mock import patch +import pandas as pd +import pytest + from pori_python.ipr.connection import IprConnection from pori_python.ipr.main import command_interface from pori_python.types import IprGene @@ -57,8 +58,8 @@ def loaded_reports(tmp_path_factory) -> Generator: json_file = tmp_path_factory.mktemp('inputs') / 'content.json' async_json_file = tmp_path_factory.mktemp('inputs') / 'async_content.json' transcript_flags_file = tmp_path_factory.mktemp('inputs') / 'transcript_flags.tsv' - patient_id = f'TEST_{str(uuid.uuid4())}' - async_patient_id = f'TEST_ASYNC_{str(uuid.uuid4())}' + patient_id = f'TEST_{uuid.uuid4()!s}' + async_patient_id = f'TEST_ASYNC_{uuid.uuid4()!s}' json_contents = { 'comparators': [ @@ -200,6 +201,7 @@ def loaded_reports(tmp_path_factory) -> Generator: sync_argslist = argslist.copy() sync_argslist.extend(['--content', str(json_file)]) + sync_argslist.extend(['--state', 'nonproduction']) with patch.object(sys, 'argv', sync_argslist): with patch.object(IprConnection, 'get_spec', return_value=get_test_spec()): command_interface() @@ -252,9 +254,7 @@ def stringify_sorted(obj): obj.pop(key, None) keys = obj.keys() for key in keys: - if isinstance(obj[key], list): - obj[key] = stringify_sorted(obj[key]) - elif isinstance(obj[key], dict): + if isinstance(obj[key], list) or isinstance(obj[key], dict): obj[key] = stringify_sorted(obj[key]) return str(obj) elif isinstance(obj, str): @@ -398,6 +398,12 @@ def test_seqqc_loaded(self, loaded_reports) -> None: assert 'seqQC' in async_report assert len(async_report['seqQC']) == 2 + def test_state_loaded(self, loaded_reports) -> None: + sync_state = get_section(loaded_reports['sync'], 'state') + async_state = get_section(loaded_reports['async'], 'state') + assert async_state == 'nonproduction' + assert sync_state == 'ready' + def test_sample_info_loaded(self, loaded_reports) -> None: sync_section = get_section(loaded_reports['sync'], 'sample-info') async_section = get_section(loaded_reports['async'], 'sample-info') @@ -448,4 +454,4 @@ def test_multivariant_multiconditionset_statements_loaded(self, loaded_reports) # we expect the two observed variant sets to have one element in common # (the kras mutation) assert len(observedVariants1) == len(observedVariants2) == 2 - assert len((set(observedVariants1 + observedVariants2))) == 3 + assert len(set(observedVariants1 + observedVariants2)) == 3 From 536bde5881c1132c2f38692d4029ebc5219f7be2 Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 14:05:04 -0700 Subject: [PATCH 03/11] remove unsupported python versions --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 32a96b2f..d871fdc5 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] + python-version: ['3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v3 From 1922a767a747caf8311093a466fb3bea73e9b80c Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 14:05:45 -0700 Subject: [PATCH 04/11] bump python version used in test --- .github/workflows/quick-pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/quick-pytest.yml b/.github/workflows/quick-pytest.yml index 5bdf6534..902de8b4 100644 --- a/.github/workflows/quick-pytest.yml +++ b/.github/workflows/quick-pytest.yml @@ -13,7 +13,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.11'] + python-version: ['3.13'] steps: - uses: actions/checkout@v3 From cd6d4d783037cd68bdf6afb1eefe98b629d4af0c Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 15:18:35 -0700 Subject: [PATCH 05/11] add state to upload tests, fix tests to align with ipr --- tests/test_ipr/test_upload.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/test_ipr/test_upload.py b/tests/test_ipr/test_upload.py index 5b7e6a93..7d544ae3 100644 --- a/tests/test_ipr/test_upload.py +++ b/tests/test_ipr/test_upload.py @@ -365,12 +365,13 @@ def test_therapeutic_targets_loaded(self, loaded_reports) -> None: def test_genomic_alterations_identified_loaded(self, loaded_reports) -> None: section = get_section(loaded_reports['sync'], 'summary/genomic-alterations-identified') variants = set([item['geneVariant'] for item in section]) + # we expect to see the observed variant name, as it appears in the test data input for variant in [ - 'FGFR2:p.R421C', + 'FGFR2:p.Arg421Cys', 'PTP4A3 (high_percentile)', 'ERBB2 (Amplification)', '(EWSR1,FLI1):fusion(e.7,e.4)', - 'CDKN2A:p.T18M', + 'CDKN2A:p.Thr18Met', ]: assert variant in variants async_section = get_section( @@ -388,21 +389,20 @@ def test_analyst_comments_loaded(self, loaded_reports) -> None: def test_seqqc_loaded(self, loaded_reports) -> None: """Test that seqQC data is present in the loaded report.""" - sync_report = loaded_reports['sync'][1]['reports'][0] - assert 'seqQC' in sync_report - assert len(sync_report['seqQC']) == 2 - samples = [item['sample'] for item in sync_report['seqQC']] + sync_section = get_section(loaded_reports['async'], 'appendices') + async_section = get_section(loaded_reports['async'], 'appendices') + + assert 'seqQC' in sync_section + assert len(sync_section['seqQC']) == 2 + samples = [item['sample'] for item in sync_section['seqQC']] assert 'Tumour DNA' in samples assert 'Constitutional DNA' in samples - async_report = loaded_reports['async'][1]['reports'][0] - assert 'seqQC' in async_report - assert len(async_report['seqQC']) == 2 + assert 'seqQC' in async_section + assert len(async_section['seqQC']) == 2 def test_state_loaded(self, loaded_reports) -> None: - sync_state = get_section(loaded_reports['sync'], 'state') - async_state = get_section(loaded_reports['async'], 'state') - assert async_state == 'nonproduction' - assert sync_state == 'ready' + assert loaded_reports['sync'][1]['reports'][0]['state'] == 'nonproduction' + assert loaded_reports['async'][1]['reports'][0]['state'] == 'ready' def test_sample_info_loaded(self, loaded_reports) -> None: sync_section = get_section(loaded_reports['sync'], 'sample-info') From d60ed430cfa48f7cbf6298861034ca0d198bb271 Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 15:18:55 -0700 Subject: [PATCH 06/11] add ipr-less state tests --- tests/test_ipr/test_main.py | 166 +++++++++++++++++++++++++++--------- 1 file changed, 128 insertions(+), 38 deletions(-) diff --git a/tests/test_ipr/test_main.py b/tests/test_ipr/test_main.py index 1dc20ab2..e8181d1c 100644 --- a/tests/test_ipr/test_main.py +++ b/tests/test_ipr/test_main.py @@ -1,13 +1,18 @@ import json import os -import pandas as pd -import pytest import sys -from typing import Dict from unittest.mock import MagicMock, patch +import pandas as pd +import pytest + from pori_python.ipr.connection import IprConnection -from pori_python.ipr.main import command_interface, load_transcript_flags +from pori_python.ipr.main import ( + command_interface, + create_report, + ipr_report, + load_transcript_flags, +) from pori_python.types import IprGene from .constants import EXCLUDE_INTEGRATION_TESTS @@ -52,8 +57,85 @@ def test_accepts_file_with_header(self, tmp_path) -> None: ] +class TestStateArgument: + """Unit tests (no network) for the report state option""" + + @staticmethod + def run_cli(tmp_path, extra_args: list[str]) -> MagicMock: + json_file = tmp_path / 'content.json' + json_file.write_text(json.dumps({'project': 'TEST'})) + argv = ['ipr', '--username', 'user', '--password', 'pass', '--content', str(json_file)] + with ( + patch.object(sys, 'argv', [*argv, *extra_args]), + patch('pori_python.ipr.main.ipr_report') as mock_ipr_report, + ): + command_interface() + return mock_ipr_report + + @staticmethod + def upload_content_for(report_function, **kwargs) -> dict: + """Run report_function up to the json upload step and return the uploaded content""" + with patch('pori_python.ipr.main.IprConnection') as mock_conn_class: + report_function( + username='user', + password='pass', + content={'project': 'TEST'}, + ipr_url='http://fake.url.ca', + upload_json=True, + **kwargs, + ) + mock_conn = mock_conn_class.return_value + assert mock_conn.upload_report.called + return mock_conn.upload_report.call_args[0][0] + + def test_cli_passes_state_to_ipr_report(self, tmp_path) -> None: + mock_ipr_report = self.run_cli(tmp_path, ['--state', 'nonproduction']) + + assert mock_ipr_report.call_args.kwargs['state'] == 'nonproduction' + + def test_cli_state_not_set_by_default(self, tmp_path) -> None: + mock_ipr_report = self.run_cli(tmp_path, []) + + assert mock_ipr_report.call_args.kwargs['state'] is None + + def test_cli_rejects_invalid_state(self, tmp_path) -> None: + with pytest.raises(SystemExit): + self.run_cli(tmp_path, ['--state', 'bogus']) + + @pytest.mark.parametrize('report_function', [ipr_report, create_report]) + def test_state_arg_set_in_output_content(self, report_function) -> None: + content = self.upload_content_for(report_function, state='nonproduction') + + assert content['state'] == 'nonproduction' + + @pytest.mark.parametrize('report_function', [ipr_report, create_report]) + def test_state_defaults_to_ready(self, report_function) -> None: + content = self.upload_content_for(report_function) + + assert content['state'] == 'ready' + + def test_empty_state_not_added(self) -> None: + content = self.upload_content_for(ipr_report, state=None) + + assert 'state' not in content + + def test_input_content_not_mutated(self) -> None: + original = {'project': 'TEST'} + with patch('pori_python.ipr.main.IprConnection'): + ipr_report( + username='user', + password='pass', + content=original, + ipr_url='http://fake.url.ca', + upload_json=True, + state='nonproduction', + ) + + assert 'state' not in original + + @pytest.fixture(scope='module') -def report_upload_content(tmp_path_factory) -> Dict: +def report_upload_content(tmp_path_factory) -> dict: mock = MagicMock() json_file = tmp_path_factory.mktemp('inputs') / 'content.json' json_file.write_text( @@ -118,32 +200,36 @@ def side_effect_function(*args, **kwargs): else: return [] - with patch.object( - sys, - 'argv', - [ - 'ipr', - '--username', - os.environ.get('IPR_USER', os.environ['USER']), - '--password', - os.environ['IPR_PASS'], - '--ipr_url', - 'http://fake.url.ca', - '--graphkb_username', - os.environ.get('GRAPHKB_USER', os.environ['USER']), - '--graphkb_password', - os.environ.get('GRAPHKB_PASS', os.environ['IPR_PASS']), - '--graphkb_url', - os.environ.get('GRAPHKB_URL', False), - '--content', - str(json_file), - '--therapeutics', - ], + with ( + patch.object( + sys, + 'argv', + [ + 'ipr', + '--username', + os.environ.get('IPR_USER', os.environ['USER']), + '--password', + os.environ['IPR_PASS'], + '--ipr_url', + 'http://fake.url.ca', + '--graphkb_username', + os.environ.get('GRAPHKB_USER', os.environ['USER']), + '--graphkb_password', + os.environ.get('GRAPHKB_PASS', os.environ['IPR_PASS']), + '--graphkb_url', + os.environ.get('GRAPHKB_URL', False), + '--content', + str(json_file), + '--therapeutics', + '--state', + 'nonproduction', + ], + ), + patch.object(IprConnection, 'upload_report', new=mock), ): - with patch.object(IprConnection, 'upload_report', new=mock): - with patch.object(IprConnection, 'get_spec', return_value=get_test_spec()): - with patch.object(IprConnection, 'get', side_effect=side_effect_function): - command_interface() + with patch.object(IprConnection, 'get_spec', return_value=get_test_spec()): + with patch.object(IprConnection, 'get', side_effect=side_effect_function): + command_interface() assert mock.called @@ -153,7 +239,7 @@ def side_effect_function(*args, **kwargs): @pytest.mark.skipif(EXCLUDE_INTEGRATION_TESTS, reason='excluding long running integration tests') class TestCreateReport: - def test_main_sections_present(self, report_upload_content: Dict) -> None: + def test_main_sections_present(self, report_upload_content: dict) -> None: sections = set(report_upload_content.keys()) for section in [ @@ -166,7 +252,11 @@ def test_main_sections_present(self, report_upload_content: Dict) -> None: ]: assert section in sections - def test_kept_low_quality_fusion(self, report_upload_content: Dict) -> None: + def test_state_set(self, report_upload_content: dict) -> None: + # the fixture passes --state nonproduction on the command line + assert report_upload_content['state'] == 'nonproduction' + + def test_kept_low_quality_fusion(self, report_upload_content: dict) -> None: fusions = [(sv['gene1'], sv['gene2']) for sv in report_upload_content['structuralVariants']] if ( EXCLUDE_BCGSC_TESTS @@ -175,32 +265,32 @@ def test_kept_low_quality_fusion(self, report_upload_content: Dict) -> None: else: assert ('SARM1', 'SUZ12') in fusions - def test_pass_through_content_added(self, report_upload_content: Dict) -> None: + def test_pass_through_content_added(self, report_upload_content: dict) -> None: # check the passthorough content was added assert 'blargh' in report_upload_content - def test_found_fusion_partner_gene(self, report_upload_content: Dict) -> None: + def test_found_fusion_partner_gene(self, report_upload_content: dict) -> None: genes = report_upload_content['genes'] # eg, A1BG assert any([g.get('knownFusionPartner', False) for g in genes]) @pytest.mark.skipif(EXCLUDE_ONCOKB_TESTS, reason='excluding tests that depend on oncokb data') - def test_found_oncogene(self, report_upload_content: Dict) -> None: + def test_found_oncogene(self, report_upload_content: dict) -> None: genes = report_upload_content['genes'] # eg, ZBTB20 assert any([g.get('oncogene', False) for g in genes]) @pytest.mark.skipif(EXCLUDE_ONCOKB_TESTS, reason='excluding tests that depend on oncokb data)') - def test_found_tumour_supressor(self, report_upload_content: Dict) -> None: + def test_found_tumour_supressor(self, report_upload_content: dict) -> None: genes = report_upload_content['genes'] # eg, ZNRF3 assert any([g.get('tumourSuppressor', False) for g in genes]) - def test_found_kb_statement_related_gene(self, report_upload_content: Dict) -> None: + def test_found_kb_statement_related_gene(self, report_upload_content: dict) -> None: genes = report_upload_content['genes'] assert any([g.get('kbStatementRelated', False) for g in genes]) @pytest.mark.skipif(EXCLUDE_ONCOKB_TESTS, reason='excluding tests that depend on oncokb data') - def test_found_cancer_gene_list_match_gene(self, report_upload_content: Dict) -> None: + def test_found_cancer_gene_list_match_gene(self, report_upload_content: dict) -> None: genes = report_upload_content['genes'] assert any([g.get('cancerGeneListMatch', False) for g in genes]) From 42973abf89d52e6921df8a1d0e1a2fd0a62bb7f9 Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 15:33:35 -0700 Subject: [PATCH 07/11] fix seqqc test typo --- tests/test_ipr/test_upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_ipr/test_upload.py b/tests/test_ipr/test_upload.py index 7d544ae3..d9d043b7 100644 --- a/tests/test_ipr/test_upload.py +++ b/tests/test_ipr/test_upload.py @@ -389,7 +389,7 @@ def test_analyst_comments_loaded(self, loaded_reports) -> None: def test_seqqc_loaded(self, loaded_reports) -> None: """Test that seqQC data is present in the loaded report.""" - sync_section = get_section(loaded_reports['async'], 'appendices') + sync_section = get_section(loaded_reports['sync'], 'appendices') async_section = get_section(loaded_reports['async'], 'appendices') assert 'seqQC' in sync_section From 818c96028f6e1a16072744d644d96def04b61662 Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 15:41:10 -0700 Subject: [PATCH 08/11] fix bug where upload json state would be overwritten --- pori_python/ipr/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pori_python/ipr/main.py b/pori_python/ipr/main.py index 05f1f21a..b677d1e7 100644 --- a/pori_python/ipr/main.py +++ b/pori_python/ipr/main.py @@ -357,7 +357,7 @@ def ipr_report( ignore_extra_fields: bool = False, tmb_high: float = TMB_SIGNATURE_HIGH_THRESHOLD, transcript_flags: str = '', - state: str = 'ready', + state: str | None = None, ) -> dict: """Run the matching and create the report JSON for upload to IPR. @@ -388,7 +388,7 @@ def ipr_report( allow_partial_matches: allow matches to statements where not all conditions are satisfied tmb_high: mutation burden threshold/cutoff to qualify as 'high' transcript_flags: path to a tsv file with two columns (no header) of transcript identifiers and flags to be added to any observed variants with matching transcript in the report upload. If header is included, it will be skipped. Matching uses direct string comparison, so transcript identifiers must match exactly, including version numbers (e.g., if input variants use ENST00000390477.1, this file must also use ENST00000390477.1, not ENST00000390477). - state: the state to create the report with if not default ('ready'). If 'nonproduction', the report will be created with state='nonproduction' in the uploaded report content + state: the state to create the report with if not default ('ready'). If 'nonproduction', the report will be created with state='nonproduction' in the uploaded report content. If uploading precreated report json, the state in the report content will be used instead of this argument. Returns: ipr_conn.upload_report return dictionary """ From 5c811627fa8c87909c772d7f2e4e8af2ff7897b2 Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 15:57:16 -0700 Subject: [PATCH 09/11] update tests --- tests/test_ipr/test_main.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/test_ipr/test_main.py b/tests/test_ipr/test_main.py index e8181d1c..bff8baf1 100644 --- a/tests/test_ipr/test_main.py +++ b/tests/test_ipr/test_main.py @@ -73,13 +73,13 @@ def run_cli(tmp_path, extra_args: list[str]) -> MagicMock: return mock_ipr_report @staticmethod - def upload_content_for(report_function, **kwargs) -> dict: + def upload_content_for(report_function, input_content=None, **kwargs) -> dict: """Run report_function up to the json upload step and return the uploaded content""" with patch('pori_python.ipr.main.IprConnection') as mock_conn_class: report_function( username='user', password='pass', - content={'project': 'TEST'}, + content=input_content if input_content is not None else {'project': 'TEST'}, ipr_url='http://fake.url.ca', upload_json=True, **kwargs, @@ -109,15 +109,29 @@ def test_state_arg_set_in_output_content(self, report_function) -> None: assert content['state'] == 'nonproduction' @pytest.mark.parametrize('report_function', [ipr_report, create_report]) - def test_state_defaults_to_ready(self, report_function) -> None: + def test_state_omitted_does_not_add_state(self, report_function) -> None: content = self.upload_content_for(report_function) - assert content['state'] == 'ready' + assert 'state' not in content - def test_empty_state_not_added(self) -> None: - content = self.upload_content_for(ipr_report, state=None) + @pytest.mark.parametrize('report_function', [ipr_report, create_report]) + @pytest.mark.parametrize('input_state', ['ready', 'nonproduction']) + def test_state_omitted_preserves_input_state(self, report_function, input_state) -> None: + content = self.upload_content_for( + report_function, input_content={'project': 'TEST', 'state': input_state} + ) - assert 'state' not in content + assert content['state'] == input_state + + @pytest.mark.parametrize('report_function', [ipr_report, create_report]) + def test_state_arg_overrides_input_state(self, report_function) -> None: + content = self.upload_content_for( + report_function, + input_content={'project': 'TEST', 'state': 'ready'}, + state='nonproduction', + ) + + assert content['state'] == 'nonproduction' def test_input_content_not_mutated(self) -> None: original = {'project': 'TEST'} From 80430bacde297bbc17123dc604330e8c8cbe2b5d Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 16:02:02 -0700 Subject: [PATCH 10/11] Update state parameter description for report upload Clarify state parameter behavior in report creation. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- pori_python/ipr/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pori_python/ipr/main.py b/pori_python/ipr/main.py index b677d1e7..551b37bc 100644 --- a/pori_python/ipr/main.py +++ b/pori_python/ipr/main.py @@ -388,7 +388,7 @@ def ipr_report( allow_partial_matches: allow matches to statements where not all conditions are satisfied tmb_high: mutation burden threshold/cutoff to qualify as 'high' transcript_flags: path to a tsv file with two columns (no header) of transcript identifiers and flags to be added to any observed variants with matching transcript in the report upload. If header is included, it will be skipped. Matching uses direct string comparison, so transcript identifiers must match exactly, including version numbers (e.g., if input variants use ENST00000390477.1, this file must also use ENST00000390477.1, not ENST00000390477). - state: the state to create the report with if not default ('ready'). If 'nonproduction', the report will be created with state='nonproduction' in the uploaded report content. If uploading precreated report json, the state in the report content will be used instead of this argument. + state: optional report state override ('ready' or 'nonproduction'). When supplied, overrides the state in content, including when uploading precreated report JSON. When omitted, preserves any state in content; if neither supplies a state, the server default ('ready') applies. Returns: ipr_conn.upload_report return dictionary """ From aae9d88c9ef04755d40bf3b43b6a25f8d697b904 Mon Sep 17 00:00:00 2001 From: Eleanor Lewis Date: Fri, 13 Nov 2026 17:11:59 -0700 Subject: [PATCH 11/11] version bump --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 8651f8a5..6b217917 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,7 +18,7 @@ known_standard_library = requests [metadata] name = pori_python -version = 1.6.0 +version = 1.7.0 url = https://github.com/bcgsc/pori_python author_email = dat@bcgsc.ca maintainer_email = dat@bcgsc.ca