Skip to content

Commit

Permalink
Merge pull request #180 from pepkit/dev_175_recordidentifier_bug
Browse files Browse the repository at this point in the history
fix #175
  • Loading branch information
donaldcampbelljr committed Apr 18, 2024
2 parents cfc8d01 + ae3ba7c commit cb64a67
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pipestat/pipestat.py
Expand Up @@ -682,7 +682,7 @@ def retrieve_one(
:param str result_identifier: single record_identifier or list of result identifiers
:return: Dict[str, any]: a mapping with filtered results reported for the record
"""
r_id = record_identifier or self.record_identifier
record_identifier = record_identifier or self.record_identifier

filter_conditions = [
{
Expand Down
33 changes: 33 additions & 0 deletions tests/test_pipestat.py
Expand Up @@ -589,6 +589,39 @@ def test_retrieve_basic(
# Test Retrieve Whole Record
assert isinstance(psm.retrieve_one(record_identifier=rec_id), Mapping)

@pytest.mark.parametrize(
["rec_id", "val"],
[
("sample1", {"name_of_something": "test_name"}),
("sample1", {"number_of_things": 2}),
],
)
@pytest.mark.parametrize("backend", ["file", "db"])
def test_retrieve_basic_no_record_identifier(
self,
rec_id,
val,
config_file_path,
results_file_path,
schema_file_path,
backend,
):
with NamedTemporaryFile() as f, ContextManagerDBTesting(DB_URL):
results_file_path = f.name
args = dict(schema_path=schema_file_path, database_only=False)
backend_data = (
{"config_file": config_file_path}
if backend == "db"
else {"results_file_path": results_file_path}
)
args.update(backend_data)
args.update(record_identifier=rec_id)
psm = SamplePipestatManager(**args)
psm.report(record_identifier=rec_id, values=val, force_overwrite=True)
assert (
psm.retrieve_one(result_identifier=list(val.keys())[0]) == list(val.items())[0][1]
)

@pytest.mark.parametrize(
["rec_id", "val"],
[
Expand Down

0 comments on commit cb64a67

Please sign in to comment.