Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #175 #180

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pipestat/pipestat.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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