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

Rename method for retrieving application tags #410

Merged
merged 2 commits into from
Aug 1, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cg_lims/EPPs/udf/calculate/get_missing_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from cg_lims.exceptions import LimsError, MissingCgFieldError, MissingUDFsError
from cg_lims.get.artifacts import get_artifacts
from cg_lims.status_db_api import StatusDBAPI

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -40,7 +41,7 @@ def check_control(artifact: Artifact) -> bool:
return all(sample.udf.get("Control") == "negative" for sample in artifact.samples)


def find_reruns(artifacts: list, status_db) -> None:
def find_reruns(artifacts: list, status_db: StatusDBAPI) -> None:
"""
Looking for artifacts to rerun.
Negative control samples are never sent for rerun.
Expand All @@ -60,8 +61,8 @@ def find_reruns(artifacts: list, status_db) -> None:
continue

try:
target_amount_reads = status_db.apptag(tag_name=app_tag, key="target_reads")
guaranteed_fraction = 0.01 * status_db.apptag(
target_amount_reads = status_db.get_application_tag(tag_name=app_tag, key="target_reads")
guaranteed_fraction = 0.01 * status_db.get_application_tag(
tag_name=app_tag, key="percent_reads_guaranteed"
)
except ConnectionError:
Expand Down
2 changes: 1 addition & 1 deletion cg_lims/EPPs/udf/set/set_samples_reads_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def get_target_amount(app_tag: str, status_db: StatusDBAPI) -> int:
"""Gets the target amount of reads from clinical-api"""
return status_db.apptag(tag_name=app_tag, key="target_reads")
return status_db.get_application_tag(tag_name=app_tag, key="target_reads")


def set_reads_missing_on_sample(sample: Sample, status_db: StatusDBAPI) -> None:
Expand Down
2 changes: 1 addition & 1 deletion cg_lims/status_db_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StatusDBAPI(object):
def __init__(self, url=None):
self.url = url

def apptag(self, tag_name, key=None, entry_point="/applications"):
def get_application_tag(self, tag_name, key=None, entry_point="/applications"):
try:
res = requests.get(self.url + entry_point + "/" + tag_name)
if key:
Expand Down
4 changes: 2 additions & 2 deletions tests/EPPs/udf/set/test_set_samples_reads_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def test_get_target_amount(mock_status_db, mock_get_udf, sample_1: Sample):

# WHEN getting the target amount of reads via the StatusDBAPI
mock_get_udf.return_value = test_app_tag
mock_status_db.apptag.return_value = 9_000_000
mock_status_db.get_application_tag.return_value = 9_000_000
result = get_target_amount(test_app_tag, mock_status_db)

# THEN the target amount of reads should be retrieved via the StatusDBAPI
assert result == 9_000_000
assert mock_status_db.apptag.mock_calls == [
assert mock_status_db.get_application_tag.mock_calls == [
mock.call(tag_name=test_app_tag, key="target_reads")
]

Expand Down
Loading