Skip to content

Commit

Permalink
modularize constants and fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
vreuter committed Nov 16, 2017
1 parent cb37516 commit e9ecad2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
5 changes: 0 additions & 5 deletions pep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
from .models import *


FLAGS = ["completed", "running", "failed", "waiting", "partial"]

GENERIC_PROTOCOL_KEY = "*"
SAMPLE_INDEPENDENT_PROJECT_SECTIONS = \
["metadata", "derived_columns", "implied_columns", "trackhubs"]
LOGGING_LEVEL = "INFO"
LOGGING_LOCATIONS = (stdout, )

Expand Down
30 changes: 30 additions & 0 deletions pep/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
""" Package constants """

__author__ = "Vince Reuter"
__email__ = "vreuter@virginia.edu"

__all__ = ["ALL_INPUTS_ATTR_NAME", "COL_KEY_SUFFIX", "COMPUTE_SETTINGS_VARNAME",
"DATA_SOURCE_COLNAME", "DATA_SOURCES_SECTION",
"DEFAULT_COMPUTE_RESOURCES_NAME", "FLAGS",
"GENERIC_PROTOCOL_KEY", "REQUIRED_INPUTS_ATTR_NAME",
"SAMPLE_ANNOTATIONS_KEY", "SAMPLE_EXECUTION_TOGGLE",
"SAMPLE_NAME_COLNAME", "SAMPLE_INDEPENDENT_PROJECT_SECTIONS",
"VALID_READ_TYPES"]


COMPUTE_SETTINGS_VARNAME = "PEPENV"
DEFAULT_COMPUTE_RESOURCES_NAME = "default"
SAMPLE_NAME_COLNAME = "sample_name"
DATA_SOURCE_COLNAME = "data_source"
SAMPLE_ANNOTATIONS_KEY = "sample_annotation"
DATA_SOURCES_SECTION = "data_sources"
SAMPLE_EXECUTION_TOGGLE = "toggle"
COL_KEY_SUFFIX = "_key"
VALID_READ_TYPES = ["single", "paired"]
REQUIRED_INPUTS_ATTR_NAME = "required_inputs_attr"
ALL_INPUTS_ATTR_NAME = "all_inputs_attr"
FLAGS = ["completed", "running", "failed", "waiting", "partial"]
GENERIC_PROTOCOL_KEY = "*"
SAMPLE_INDEPENDENT_PROJECT_SECTIONS = \
["metadata", "derived_columns", "implied_columns", "trackhubs"]

13 changes: 1 addition & 12 deletions pep/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import pandas as _pd
import yaml

from .const import *
from .utils import \
add_project_sample_constants, alpha_cased, check_bam, check_fastq, \
expandpath, get_file_size, grab_project_data, import_from_source, \
Expand All @@ -82,18 +83,6 @@
__all__ = __functions__ + __classes__


COMPUTE_SETTINGS_VARNAME = "PEPENV"
DEFAULT_COMPUTE_RESOURCES_NAME = "default"
SAMPLE_NAME_COLNAME = "sample_name"
DATA_SOURCE_COLNAME = "data_source"
SAMPLE_ANNOTATIONS_KEY = "sample_annotation"
DATA_SOURCES_SECTION = "data_sources"
SAMPLE_EXECUTION_TOGGLE = "toggle"
COL_KEY_SUFFIX = "_key"
VALID_READ_TYPES = ["single", "paired"]
REQUIRED_INPUTS_ATTR_NAME = "required_inputs_attr"
ALL_INPUTS_ATTR_NAME = "all_inputs_attr"

ATTRDICT_METADATA = {"_force_nulls": False, "_attribute_identity": False}

_LOGGER = logging.getLogger(__name__)
Expand Down
7 changes: 2 additions & 5 deletions pep/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
""" Helpers without an obvious logical home. """

from collections import defaultdict, Iterable
import copy
import contextlib
import logging
import os
Expand All @@ -11,9 +10,7 @@

import yaml

from . import \
GENERIC_PROTOCOL_KEY, SAMPLE_INDEPENDENT_PROJECT_SECTIONS, \
SAMPLE_NAME_COLNAME
from .const import GENERIC_PROTOCOL_KEY, SAMPLE_INDEPENDENT_PROJECT_SECTIONS


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -299,7 +296,7 @@ def sample_folder(prj, sample):
:return str: this Project's root folder for the given Sample
"""
return os.path.join(prj.metadata.results_subdir,
sample[SAMPLE_NAME_COLNAME])
sample["sample_name"])



Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import copy
import mock
import pytest
from pep import SAMPLE_INDEPENDENT_PROJECT_SECTIONS, SAMPLE_NAME_COLNAME
from pep.const import SAMPLE_INDEPENDENT_PROJECT_SECTIONS, SAMPLE_NAME_COLNAME
from pep.models import AttributeDict, Project, Sample
from pep.utils import add_project_sample_constants, grab_project_data
from tests.helpers import named_param, nonempty_powerset
Expand Down

0 comments on commit e9ecad2

Please sign in to comment.