Skip to content

Commit

Permalink
Apply black formatting settings to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelDuffin committed Jul 10, 2024
1 parent 1ceaf6f commit 5dc5f81
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 213 deletions.
5 changes: 4 additions & 1 deletion ad_email/ad_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- AdEmail
Send email to recipient via SMTP
"""

import sys
import os
import jinja2
Expand Down Expand Up @@ -111,7 +112,9 @@ def send_email(
self.msg["Subject"] = email_subject
self.msg["From"] = self.sender
self.msg["To"] = recipients
self.msg.attach(MIMEText(email_message, "html", "utf-8")) # Add msg to e-mail body
self.msg.attach(
MIMEText(email_message, "html", "utf-8")
) # Add msg to e-mail body
self.logger.info(self.logger.log_msgs["sending_email"], self.msg)
# Configure SMTP server connection for sending email
with smtplib.SMTP(
Expand Down
2 changes: 2 additions & 0 deletions ad_email/test_ad_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
N.B. test_email_sending_success() will only pass when running on the
workstation where the required auth details are stored
"""

import os
import pytest
from ad_email.ad_email import AdEmail
Expand All @@ -12,6 +13,7 @@

# TODO finish this test suite as it is currently incomplete


@pytest.fixture(scope="function")
def logger_obj():
temp_log = os.path.join(test_data_temp, "temp.log")
Expand Down
5 changes: 3 additions & 2 deletions ad_logger/ad_logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Automate demultiplex logging. Classes required for logging
"""

import sys
import re
import logging
Expand Down Expand Up @@ -38,7 +39,7 @@ def set_root_logger() -> object:
as the root logger will use these same syslog handler and stream handler
:return logger: Logging object
"""
sensitive_formatter=SensitiveFormatter(get_logging_formatter())
sensitive_formatter = SensitiveFormatter(get_logging_formatter())
logger = logging.getLogger(AdLoggerConfig.REPO_NAME)
stream_handler = logging.StreamHandler(sys.stdout)
stream_handler.setFormatter(sensitive_formatter)
Expand All @@ -53,7 +54,7 @@ def set_root_logger() -> object:
handlers=[
stream_handler,
syslog_handler,
]
],
)
return logger

Expand Down
2 changes: 1 addition & 1 deletion ad_logger/test_ad_logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" ad_logger.py pytest unit tests. The test suite is currently incomplete
"""

import pytest
from toolbox import toolbox
from ad_logger import ad_logger
Expand Down Expand Up @@ -47,4 +48,3 @@ def test_get_loggers(self, logfiles_config, caplog):
f"Test log message. Logger {loggers[logger_name].name}"
)
assert loggers[logger_name].name in caplog.text

21 changes: 15 additions & 6 deletions config/ad_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- ToolboxConfig
- URConfig
"""

import os
import sys
import datetime
Expand Down Expand Up @@ -86,7 +87,9 @@
# DNAnexus upload agent path
UPLOAD_AGENT_EXE = f"{DOCUMENT_ROOT}/apps/dnanexus-upload-agent-1.5.17-linux/ua"
BCL2FASTQ_DOCKER = "seglh/bcl2fastq2:v2.20.0.422_60dbb5a"
GATK_DOCKER = "broadinstitute/gatk:4.1.8.1" # TODO this image should have a hash added in future
GATK_DOCKER = (
"broadinstitute/gatk:4.1.8.1" # TODO this image should have a hash added in future
)

LANE_METRICS_SUFFIX = ".illumina_lane_metrics"
DEMUX_NOT_REQUIRED_MSG = "%s run. Does not need demultiplexing locally"
Expand Down Expand Up @@ -262,7 +265,10 @@

DX_CMDS = {
"create_proj": 'PROJECT_ID="$(dx new project --bill-to %s "%s" --brief --auth ${AUTH})"',
"find_proj_name": f"{SDK_SOURCE}; dx find projects --name *%s* " "--auth %s | awk '{print $3}'",
"find_proj_name": (
f"{SDK_SOURCE}; dx find projects --name *%s* "
"--auth %s | awk '{print $3}'"
),
"proj_name_from_id": f"{SDK_SOURCE}; dx describe %s --auth %s --json | jq -r .name",
"find_proj_id": f"{SDK_SOURCE}; dx describe %s --auth %s --json | jq -r .id",
"find_execution_id": (
Expand Down Expand Up @@ -366,7 +372,7 @@ class DemultiplexConfig(PanelConfig):
"checksums_do_not_match": "Checksums do not match", # Failure message written to md5sum file by integrity check scripts
"samplesheet_success": "Samplesheet check successful with no errors identified: %s",
"samplesheet_fail": "Processing halted. SampleSheet contains SampleSheet errors: %s ",
"upload_flag_umis": "Runfolder contains UMIs. Runfolder will not be uploaded and requires manual upload: %s"
"upload_flag_umis": "Runfolder contains UMIs. Runfolder will not be uploaded and requires manual upload: %s",
}
TESTING = TESTING
BCL2FASTQ2_CMD = (
Expand Down Expand Up @@ -417,7 +423,7 @@ class SWConfig(PanelConfig):
RUNFOLDERS = RUNFOLDERS
PROD_ORGANISATION = "org-viapath_prod" # Prod org for billing
if BRANCH == "main": # Prod branch

BSPS_ID = "BSPS_MD"
DNANEXUS_USERS = { # User access level
# TODO remove InterpretationRequest user once per-user accounts set up
Expand Down Expand Up @@ -538,6 +544,7 @@ class ToolboxConfig(PanelConfig):
"""
Toolbox configuration
"""

if BRANCH == "master":
DNANEXUS_PROJECT_PREFIX = "002_" # Denotes production status of run
else:
Expand Down Expand Up @@ -597,11 +604,13 @@ class URConfig:
"upload_started": "Upload started", # Statement to write to DNAnexus upload started file
}

class RunfolderCleanupConfig():

class RunfolderCleanupConfig:
"""
Runfolder Cleanup configuration
"""

TIMESTAMP = TIMESTAMP
RUNFOLDER_PATTERN = RUNFOLDER_PATTERN
RUNFOLDERS = RUNFOLDERS
CREDENTIALS = CREDENTIALS
CREDENTIALS = CREDENTIALS
1 change: 1 addition & 0 deletions config/panel_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
dry_lab True if required to share with dry lab, None if not
umis True if run has UMIs
"""

# TODO in future do we want to swap physical paths for file IDs

TOOLS_PROJECT = "project-ByfFPz00jy1fk6PjpZ95F27J" # 001_ToolsReferenceData
Expand Down
11 changes: 9 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
Variables used across test modules, including the setup and teardown fixture
that is run before and after every test. This is the top-level testing configuration
"""

import os
import re
import shutil
import pytest
import tarfile
import logging
from shutil import copy

# sys.path.append("..")
from ad_logger import ad_logger
from toolbox import toolbox
Expand Down Expand Up @@ -65,6 +67,7 @@
},
]


def patch_toolbox(monkeypatch):
"""
Apply patches required for toolbox script. These point the paths to the
Expand Down Expand Up @@ -103,7 +106,9 @@ def run_before_and_after_session():
for destination in to_copy_interop_to:
shutil.copytree(os.path.join(test_data_dir_unzipped, "InterOp"), destination)

test_data_unzipped = os.path.join(test_data_dir_unzipped, "demultiplex_test_files", "test_runfolders")
test_data_unzipped = os.path.join(
test_data_dir_unzipped, "demultiplex_test_files", "test_runfolders"
)

directories = [
os.path.join(test_data_unzipped, d)
Expand All @@ -114,7 +119,9 @@ def run_before_and_after_session():

for directory in directories:
if re.match(".*999999_.*", directory):
fastqs_dir = os.path.join(test_data_unzipped, directory, "Data", "Intensities", "BaseCalls/")
fastqs_dir = os.path.join(
test_data_unzipped, directory, "Data", "Intensities", "BaseCalls/"
)
os.makedirs(fastqs_dir, exist_ok=True)
copy(dummy_fastq, fastqs_dir)
yield # Where the testing happens
Expand Down
Loading

0 comments on commit 5dc5f81

Please sign in to comment.