Skip to content

Commit

Permalink
Add multiprocessing (#112)
Browse files Browse the repository at this point in the history
* Add multiprocessing to the association study function
* Add multiprocessing to interaction tests
* Fix github actions
* Version 2.1.0
  • Loading branch information
jrm5100 committed Jul 15, 2021
1 parent 4b844a1 commit 8059a0c
Show file tree
Hide file tree
Showing 14 changed files with 654 additions and 389 deletions.
56 changes: 35 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,46 @@ jobs:
python-version: 3.7

- name: Install Poetry
uses: snok/install-poetry@v1.1.2

- name: Cache Poetry virtualenv
uses: actions/cache@v1
id: cache
uses: snok/install-poetry@v1.1.6
with:
path: ~/.virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ hashFiles('**/poetry.lock') }}
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: |
poetry install
if: steps.cache.outputs.cache-hit != 'true'
virtualenvs-create: true
virtualenvs-in-project: true

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction

#----------------------------------------------
# Activate Env
#----------------------------------------------

- name: Code Quality
run: poetry run black . --check
run: |
source .venv/bin/activate
black . --check
- name: Test with pytest
run: poetry run pytest -n 2 --cov . --cov-report=xml
run: |
source .venv/bin/activate
pytest -n 2 --cov . --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Expand Down
2 changes: 0 additions & 2 deletions clarite/cli/commands/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def ewas(
covariates=covariates,
data=data,
survey_design_spec=sd,
cov_method=covariance_calc,
min_n=min_n,
)
# Save
Expand Down Expand Up @@ -281,7 +280,6 @@ def ewas_r(
covariates=covariates,
data=data,
survey_design_spec=sd,
cov_method=covariance_calc,
min_n=min_n,
)
# Save
Expand Down
10 changes: 5 additions & 5 deletions clarite/modules/analyze/regression/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,13 @@ def _log_errors_and_warnings(self):
for warning in warning_list:
click.echo(click.style(f"\t{warning}", fg="yellow"))

def _check_covariate_values(self, keep_row_mask) -> Tuple[List[str], List[str]]:
@staticmethod
def _check_covariate_values(
data, covariates, keep_row_mask
) -> Tuple[List[str], List[str]]:
"""Remove covariates that do not vary, warning when this occurs"""
warnings = []
unique_values = self.data.loc[keep_row_mask, self.covariates].nunique()
unique_values = data.loc[keep_row_mask, covariates].nunique()
varying_covars = list(unique_values[unique_values > 1].index.values)
non_varying_covars = list(unique_values[unique_values <= 1].index.values)
if len(non_varying_covars) > 0:
Expand All @@ -181,9 +184,6 @@ def _check_covariate_values(self, keep_row_mask) -> Tuple[List[str], List[str]]:
)
return varying_covars, warnings

def _encode_var_name(self, varname):
"""Replace variable names"""

@abstractmethod
def run(self) -> None:
"""Run the regression"""
Expand Down

0 comments on commit 8059a0c

Please sign in to comment.