Skip to content

Commit 8059a0c

Browse files
authored
Add multiprocessing (#112)
* Add multiprocessing to the association study function * Add multiprocessing to interaction tests * Fix github actions * Version 2.1.0
1 parent 4b844a1 commit 8059a0c

File tree

14 files changed

+654
-389
lines changed

14 files changed

+654
-389
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,46 @@ jobs:
4242
python-version: 3.7
4343

4444
- name: Install Poetry
45-
uses: snok/[email protected]
46-
47-
- name: Cache Poetry virtualenv
48-
uses: actions/cache@v1
49-
id: cache
45+
uses: snok/[email protected]
5046
with:
51-
path: ~/.virtualenvs
52-
key: poetry-${{ hashFiles('**/poetry.lock') }}
53-
restore-keys: |
54-
poetry-${{ hashFiles('**/poetry.lock') }}
55-
56-
- name: Set Poetry config
57-
run: |
58-
poetry config virtualenvs.in-project false
59-
poetry config virtualenvs.path ~/.virtualenvs
60-
61-
- name: Install Dependencies
62-
run: |
63-
poetry install
64-
if: steps.cache.outputs.cache-hit != 'true'
47+
virtualenvs-create: true
48+
virtualenvs-in-project: true
49+
50+
#----------------------------------------------
51+
# load cached venv if cache exists
52+
#----------------------------------------------
53+
- name: Load cached venv
54+
id: cached-poetry-dependencies
55+
uses: actions/cache@v2
56+
with:
57+
path: .venv
58+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
59+
#----------------------------------------------
60+
# install dependencies if cache does not exist
61+
#----------------------------------------------
62+
- name: Install dependencies
63+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
64+
run: poetry install --no-interaction --no-root
65+
66+
#----------------------------------------------
67+
# install your root project, if required
68+
#----------------------------------------------
69+
- name: Install library
70+
run: poetry install --no-interaction
71+
72+
#----------------------------------------------
73+
# Activate Env
74+
#----------------------------------------------
6575

6676
- name: Code Quality
67-
run: poetry run black . --check
77+
run: |
78+
source .venv/bin/activate
79+
black . --check
6880
6981
- name: Test with pytest
70-
run: poetry run pytest -n 2 --cov . --cov-report=xml
82+
run: |
83+
source .venv/bin/activate
84+
pytest -n 2 --cov . --cov-report=xml
7185
7286
- name: Upload coverage to Codecov
7387
uses: codecov/codecov-action@v1

clarite/cli/commands/analyze.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ def ewas(
143143
covariates=covariates,
144144
data=data,
145145
survey_design_spec=sd,
146-
cov_method=covariance_calc,
147146
min_n=min_n,
148147
)
149148
# Save
@@ -281,7 +280,6 @@ def ewas_r(
281280
covariates=covariates,
282281
data=data,
283282
survey_design_spec=sd,
284-
cov_method=covariance_calc,
285283
min_n=min_n,
286284
)
287285
# Save

clarite/modules/analyze/regression/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,13 @@ def _log_errors_and_warnings(self):
169169
for warning in warning_list:
170170
click.echo(click.style(f"\t{warning}", fg="yellow"))
171171

172-
def _check_covariate_values(self, keep_row_mask) -> Tuple[List[str], List[str]]:
172+
@staticmethod
173+
def _check_covariate_values(
174+
data, covariates, keep_row_mask
175+
) -> Tuple[List[str], List[str]]:
173176
"""Remove covariates that do not vary, warning when this occurs"""
174177
warnings = []
175-
unique_values = self.data.loc[keep_row_mask, self.covariates].nunique()
178+
unique_values = data.loc[keep_row_mask, covariates].nunique()
176179
varying_covars = list(unique_values[unique_values > 1].index.values)
177180
non_varying_covars = list(unique_values[unique_values <= 1].index.values)
178181
if len(non_varying_covars) > 0:
@@ -181,9 +184,6 @@ def _check_covariate_values(self, keep_row_mask) -> Tuple[List[str], List[str]]:
181184
)
182185
return varying_covars, warnings
183186

184-
def _encode_var_name(self, varname):
185-
"""Replace variable names"""
186-
187187
@abstractmethod
188188
def run(self) -> None:
189189
"""Run the regression"""

0 commit comments

Comments
 (0)