Skip to content

Commit

Permalink
Fix id parameter showing builtin "id"
Browse files Browse the repository at this point in the history
Fix docstrings with single rather than triple quotes.
  • Loading branch information
kjsanger committed Sep 23, 2024
1 parent 337733b commit 6b983eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/npg_notify/db/mlwh.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.

from sqlalchemy import ForeignKey, Integer, String, UniqueConstraint, select
from sqlalchemy import DateTime, ForeignKey, Integer, String, UniqueConstraint, select
from sqlalchemy.exc import NoResultFound
from sqlalchemy.orm import (
DeclarativeBase,
Expand Down Expand Up @@ -46,7 +46,7 @@ class Base(DeclarativeBase):


class Study(Base):
"A representation for the 'study' table."
"""A representation for the 'study' table."""

__tablename__ = "study"

Expand Down Expand Up @@ -89,7 +89,7 @@ def contacts(self) -> list[str]:


class StudyUser(Base):
"A representation for the 'study_users' table."
"""A representation for the 'study_users' table."""

__tablename__ = "study_users"

Expand All @@ -111,18 +111,18 @@ def __repr__(self):


class StudyNotFoundError(Exception):
"An error to use when a study does not exist in mlwh."
"""An error to use when a study does not exist in mlwh."""

pass


def get_study_contacts(session: Session, id: str) -> list[str]:
def get_study_contacts(session: Session, study_id: str) -> list[str]:
"""Retrieves emails of study contacts from the mlwh database.
Args:
session:
sqlalchemy.orm.Session object
id:
study_id:
String study ID.
Returns:
Expand All @@ -136,13 +136,13 @@ def get_study_contacts(session: Session, id: str) -> list[str]:
"""
try:
contacts = (
session.execute(select(Study).where(Study.id_study_lims == id))
session.execute(select(Study).where(Study.id_study_lims == study_id))
.scalar_one()
.contacts()
)
except NoResultFound:
raise StudyNotFoundError(
f"Study with ID {id} is not found in ml warehouse"
f"Study with ID {study_id} is not found in ml warehouse"
)

return contacts
2 changes: 1 addition & 1 deletion src/npg_notify/porch_wrapper/qc_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def process_task(conf_file_path) -> bool:
) as session:
for study_id in study_ids:
contacts_per_study[study_id] = get_study_contacts(
session=session, id=study_id
session=session, study_id=study_id
)

except Exception as err:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_retrieve_contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def test_retrieving_study_contacts(mlwh_test_session):
):
get_study_contacts(mlwh_test_session, "666")

for id in ["2", "5", "4"]:
assert get_study_contacts(mlwh_test_session, id) == []
for study_id in ["2", "5", "4"]:
assert get_study_contacts(mlwh_test_session, study_id) == []

users = ["owner", "user1", "user2", "user3"]
assert get_study_contacts(mlwh_test_session, "3") == [
Expand Down

0 comments on commit 6b983eb

Please sign in to comment.