Skip to content

Commit

Permalink
Merge pull request #6 from DoubleML/fix-ci
Browse files Browse the repository at this point in the history
Fix GitHub Actions CI
  • Loading branch information
MalteKurz authored Jun 15, 2022
2 parents 6074727 + fdc7db9 commit 7a95d0d
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install pytest xgboost
pip install -r requirements.txt
pip install .
- name: Test with pytest
run: |
pytest
pytest doubleml_serverless/
30 changes: 15 additions & 15 deletions doubleml_serverless/double_ml_iivm_aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ def __init__(self,
draw_sample_splitting=True,
apply_cross_fitting=True):
DoubleMLIIVM.__init__(self,
obj_dml_data,
ml_g,
ml_m,
ml_r,
n_folds,
n_rep,
score,
subgroups,
dml_procedure,
trimming_rule,
trimming_threshold,
draw_sample_splitting,
apply_cross_fitting)
obj_dml_data=obj_dml_data,
ml_g=ml_g,
ml_m=ml_m,
ml_r=ml_r,
n_folds=n_folds,
n_rep=n_rep,
score=score,
subgroups=subgroups,
dml_procedure=dml_procedure,
trimming_rule=trimming_rule,
trimming_threshold=trimming_threshold,
draw_sample_splitting=draw_sample_splitting,
apply_cross_fitting=apply_cross_fitting)
DoubleMLLambda.__init__(self,
lambda_function_name,
aws_region)
lambda_function_name=lambda_function_name,
aws_region=aws_region)

def _ml_nuisance_aws_lambda(self, cv_params):
assert self._dml_data.n_treat == 1
Expand Down
27 changes: 13 additions & 14 deletions doubleml_serverless/double_ml_irm_aws_lambda.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from doubleml import DoubleMLIRM
import numpy as np
from sklearn.utils import check_X_y

from ._helper import _get_cond_smpls
Expand All @@ -24,20 +23,20 @@ def __init__(self,
draw_sample_splitting=True,
apply_cross_fitting=True):
DoubleMLIRM.__init__(self,
obj_dml_data,
ml_g,
ml_m,
n_folds,
n_rep,
score,
dml_procedure,
trimming_rule,
trimming_threshold,
draw_sample_splitting,
apply_cross_fitting)
obj_dml_data=obj_dml_data,
ml_g=ml_g,
ml_m=ml_m,
n_folds=n_folds,
n_rep=n_rep,
score=score,
dml_procedure=dml_procedure,
trimming_rule=trimming_rule,
trimming_threshold=trimming_threshold,
draw_sample_splitting=draw_sample_splitting,
apply_cross_fitting=apply_cross_fitting)
DoubleMLLambda.__init__(self,
lambda_function_name,
aws_region)
lambda_function_name=lambda_function_name,
aws_region=aws_region)

def _ml_nuisance_aws_lambda(self, cv_params):
assert self._dml_data.n_treat == 1
Expand Down
37 changes: 19 additions & 18 deletions doubleml_serverless/double_ml_pliv_aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self,
lambda_function_name,
aws_region,
obj_dml_data,
ml_g,
ml_l,
ml_m,
ml_r,
n_folds=5,
Expand All @@ -21,19 +21,19 @@ def __init__(self,
draw_sample_splitting=True,
apply_cross_fitting=True):
DoubleMLPLIV.__init__(self,
obj_dml_data,
ml_g,
ml_m,
ml_r,
n_folds,
n_rep,
score,
dml_procedure,
draw_sample_splitting,
apply_cross_fitting)
obj_dml_data=obj_dml_data,
ml_l=ml_l,
ml_m=ml_m,
ml_r=ml_r,
n_folds=n_folds,
n_rep=n_rep,
score=score,
dml_procedure=dml_procedure,
draw_sample_splitting=draw_sample_splitting,
apply_cross_fitting=apply_cross_fitting)
DoubleMLLambda.__init__(self,
lambda_function_name,
aws_region)
lambda_function_name=lambda_function_name,
aws_region=aws_region)

def _ml_nuisance_aws_lambda(self, cv_params):
assert self._dml_data.n_treat == 1
Expand All @@ -47,12 +47,12 @@ def _ml_nuisance_aws_lambda(self, cv_params):

payload = self._dml_data.get_payload()

payload_ml_g = payload.copy()
payload_ml_l = payload.copy()
payload_ml_m = payload.copy()
payload_ml_r = payload.copy()

_attach_learner(payload_ml_g,
'ml_g', self.learner['ml_g'],
_attach_learner(payload_ml_l,
'ml_l', self.learner['ml_l'],
self._dml_data.y_col, self._dml_data.x_cols)

_attach_learner(payload_ml_m,
Expand All @@ -63,7 +63,7 @@ def _ml_nuisance_aws_lambda(self, cv_params):
'ml_r', self.learner['ml_r'],
self._dml_data.d_cols[0], self._dml_data.x_cols)

payloads = _attach_smpls([payload_ml_g, payload_ml_m, payload_ml_r],
payloads = _attach_smpls([payload_ml_l, payload_ml_m, payload_ml_r],
[self.smpls, self.smpls, self.smpls],
self.n_folds,
self.n_rep,
Expand All @@ -80,9 +80,10 @@ def _ml_nuisance_aws_lambda(self, cv_params):
# compute score elements
self._psi_a[:, i_rep, self._i_treat], self._psi_b[:, i_rep, self._i_treat] = \
self._score_elements(y, z, d,
preds['ml_g'][:, i_rep],
preds['ml_l'][:, i_rep],
preds['ml_m'][:, i_rep],
preds['ml_r'][:, i_rep],
None,
self.smpls[i_rep])

return
38 changes: 19 additions & 19 deletions doubleml_serverless/double_ml_plr_aws_lambda.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from doubleml import DoubleMLPLR
import numpy as np
from sklearn.utils import check_X_y

from .double_ml_aws_lambda import DoubleMLLambda
from ._helper import _attach_learner, _attach_smpls, _extract_preds
from ._helper import _attach_learner, _attach_smpls


class DoubleMLPLRServerless(DoubleMLPLR, DoubleMLLambda):
def __init__(self,
lambda_function_name,
aws_region,
obj_dml_data,
ml_g,
ml_l,
ml_m,
n_folds=5,
n_rep=1,
Expand All @@ -20,18 +19,18 @@ def __init__(self,
draw_sample_splitting=True,
apply_cross_fitting=True):
DoubleMLPLR.__init__(self,
obj_dml_data,
ml_g,
ml_m,
n_folds,
n_rep,
score,
dml_procedure,
draw_sample_splitting,
apply_cross_fitting)
obj_dml_data=obj_dml_data,
ml_l=ml_l,
ml_m=ml_m,
n_folds=n_folds,
n_rep=n_rep,
score=score,
dml_procedure=dml_procedure,
draw_sample_splitting=draw_sample_splitting,
apply_cross_fitting=apply_cross_fitting)
DoubleMLLambda.__init__(self,
lambda_function_name,
aws_region)
lambda_function_name=lambda_function_name,
aws_region=aws_region)

def _ml_nuisance_aws_lambda(self, cv_params):
assert self._dml_data.n_treat == 1
Expand All @@ -42,18 +41,18 @@ def _ml_nuisance_aws_lambda(self, cv_params):

payload = self._dml_data.get_payload()

payload_ml_g = payload.copy()
payload_ml_l = payload.copy()
payload_ml_m = payload.copy()

_attach_learner(payload_ml_g,
'ml_g', self.learner['ml_g'],
_attach_learner(payload_ml_l,
'ml_l', self.learner['ml_l'],
self._dml_data.y_col, self._dml_data.x_cols)

_attach_learner(payload_ml_m,
'ml_m', self.learner['ml_m'],
self._dml_data.d_cols[0], self._dml_data.x_cols)

payloads = _attach_smpls([payload_ml_g, payload_ml_m],
payloads = _attach_smpls([payload_ml_l, payload_ml_m],
[self.smpls, self.smpls],
self.n_folds,
self.n_rep,
Expand All @@ -70,8 +69,9 @@ def _ml_nuisance_aws_lambda(self, cv_params):
# compute score elements
self._psi_a[:, i_rep, self._i_treat], self._psi_b[:, i_rep, self._i_treat] = \
self._score_elements(y, d,
preds['ml_g'][:, i_rep],
preds['ml_l'][:, i_rep],
preds['ml_m'][:, i_rep],
None,
self.smpls[i_rep])

return
20 changes: 10 additions & 10 deletions doubleml_serverless/tests/test_pliv.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ def dml_pliv_fixture(generate_data_pliv, idx, learner, score, dml_procedure):
x_cols = data.columns[data.columns.str.startswith('X')].tolist()

# Set machine learning methods for m & g
ml_g = clone(learner)
ml_l = clone(learner)
ml_m = clone(learner)
ml_r = clone(learner)

np.random.seed(3141)
dml_data_json = dml_lambda.DoubleMLDataJson(data, 'y', ['d'], x_cols, 'Z1')
dml_pliv_lambda = DoubleMLPLIVServerlessLocal('local', 'local',
dml_data_json,
ml_g, ml_m, ml_r,
n_folds,
ml_l, ml_m, ml_r,
n_folds=n_folds,
score=score,
dml_procedure=dml_procedure)

Expand All @@ -76,8 +76,8 @@ def dml_pliv_fixture(generate_data_pliv, idx, learner, score, dml_procedure):
np.random.seed(3141)
dml_data = dml.DoubleMLData(data, 'y', ['d'], x_cols, 'Z1')
dml_pliv = dml.DoubleMLPLIV(dml_data,
ml_g, ml_m, ml_r,
n_folds,
ml_l, ml_m, ml_r,
n_folds=n_folds,
score=score,
dml_procedure=dml_procedure)

Expand Down Expand Up @@ -140,7 +140,7 @@ def dml_pliv_scaling_fixture(generate_data_pliv, idx, learner, score, dml_proced
x_cols = data.columns[data.columns.str.startswith('X')].tolist()

# Set machine learning methods for m & g
ml_g = clone(learner)
ml_l = clone(learner)
ml_m = clone(learner)
ml_r = clone(learner)

Expand All @@ -149,8 +149,8 @@ def dml_pliv_scaling_fixture(generate_data_pliv, idx, learner, score, dml_proced
np.random.seed(3141)
dml_pliv_folds = DoubleMLPLIVServerlessLocal('local', 'local',
dml_data_json,
ml_g, ml_m, ml_r,
n_folds,
ml_l, ml_m, ml_r,
n_folds=n_folds,
score=score,
dml_procedure=dml_procedure)

Expand All @@ -159,8 +159,8 @@ def dml_pliv_scaling_fixture(generate_data_pliv, idx, learner, score, dml_proced
np.random.seed(3141)
dml_pliv_reps = DoubleMLPLIVServerlessLocal('local', 'local',
dml_data_json,
ml_g, ml_m, ml_r,
n_folds,
ml_l, ml_m, ml_r,
n_folds=n_folds,
score=score,
dml_procedure=dml_procedure)

Expand Down
22 changes: 11 additions & 11 deletions doubleml_serverless/tests/test_plr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def learner(request):


@pytest.fixture(scope='module',
params=['IV-type', 'partialling out'])
params=['partialling out'])
def score(request):
return request.param

Expand All @@ -58,15 +58,15 @@ def dml_plr_fixture(generate_data_plr, idx, learner, score, dml_procedure):
x_cols = data.columns[data.columns.str.startswith('X')].tolist()

# Set machine learning methods for m & g
ml_g = clone(learner)
ml_l = clone(learner)
ml_m = clone(learner)

np.random.seed(3141)
dml_data_json = dml_lambda.DoubleMLDataJson(data, 'y', ['d'], x_cols)
dml_plr_lambda = DoubleMLPLRServerlessLocal('local', 'local',
dml_data_json,
ml_g, ml_m,
n_folds,
ml_l, ml_m,
n_folds=n_folds,
score=score,
dml_procedure=dml_procedure)

Expand All @@ -75,8 +75,8 @@ def dml_plr_fixture(generate_data_plr, idx, learner, score, dml_procedure):
np.random.seed(3141)
dml_data = dml.DoubleMLData(data, 'y', ['d'], x_cols)
dml_plr = dml.DoubleMLPLR(dml_data,
ml_g, ml_m,
n_folds,
ml_l, ml_m,
n_folds=n_folds,
score=score,
dml_procedure=dml_procedure)

Expand Down Expand Up @@ -139,16 +139,16 @@ def dml_plr_scaling_fixture(generate_data_plr, idx, learner, score, dml_procedur
x_cols = data.columns[data.columns.str.startswith('X')].tolist()

# Set machine learning methods for m & g
ml_g = clone(learner)
ml_l = clone(learner)
ml_m = clone(learner)

dml_data_json = dml_lambda.DoubleMLDataJson(data, 'y', ['d'], x_cols)

np.random.seed(3141)
dml_plr_folds = DoubleMLPLRServerlessLocal('local', 'local',
dml_data_json,
ml_g, ml_m,
n_folds,
ml_l, ml_m,
n_folds=n_folds,
score=score,
dml_procedure=dml_procedure)

Expand All @@ -157,8 +157,8 @@ def dml_plr_scaling_fixture(generate_data_plr, idx, learner, score, dml_procedur
np.random.seed(3141)
dml_plr_reps = DoubleMLPLRServerlessLocal('local', 'local',
dml_data_json,
ml_g, ml_m,
n_folds,
ml_l, ml_m,
n_folds=n_folds,
score=score,
dml_procedure=dml_procedure)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DoubleML>=0.2.2
DoubleML>=0.5.0
joblib
numpy
pandas
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
url='https://github.com/DoubleML/doubleml-serverless',
packages=find_packages(exclude=['aws_lambda_app*']),
install_requires=[
'DoubleML>=0.2.2',
'DoubleML>=0.5.0',
'joblib',
'numpy',
'pandas',
Expand Down

0 comments on commit 7a95d0d

Please sign in to comment.