Skip to content

Commit aac9661

Browse files
authored
[REL] Latest updates + New CI : Merge pull request #141 from FenTechSolutions/circleci-project-setup
[REL] Latest updates + New CI
2 parents e43d8ff + d244668 commit aac9661

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+15181
-3760
lines changed

.circleci/bumpversion.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
VERSION=$(cat setup.py| grep version | cut -c 20- | rev | cut -c 3- | rev)
4+
COMMIT_MESSAGE="$(git log --format=%B -n 1)"
5+
6+
git config --global user.email "[email protected]"
7+
git config --global user.name "CircleCI Bumpversion"
8+
git config --global push.default simple
9+
pip install bumpversion
10+
if [[ $COMMIT_MESSAGE == *"[NV]"* ]] || [[ $COMMIT_MESSAGE == *"[DOC]"* ]];
11+
then echo "No version update";
12+
elif [[ $COMMIT_MESSAGE == *"[REL]"* ]];
13+
then bumpversion --current-version $VERSION minor setup.py README.md docs/index.rst docs/conf.py cdt/__init__.py;
14+
elif [[ $COMMIT_MESSAGE == *"[MREL]"* ]];
15+
then bumpversion --current-version $VERSION major setup.py README.md docs/index.rst docs/conf.py cdt/__init__.py;
16+
else bumpversion --current-version $VERSION patch setup.py README.md docs/index.rst docs/conf.py cdt/__init__.py;
17+
fi

.circleci/config.yml

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# Use the latest 2.1 version of CircleCI pipeline process engine.
2+
# See: https://circleci.com/docs/2.0/configuration-reference
3+
version: 2.1
4+
5+
jobs:
6+
7+
build-test:
8+
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
9+
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
10+
docker:
11+
- image: docker:17.05.0-ce-git
12+
auth:
13+
username: $DOCKER_USER
14+
password: $DOCKER_PASS
15+
16+
# Add steps to the job
17+
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
18+
steps:
19+
- checkout
20+
- setup_remote_docker
21+
- run:
22+
name: "Build test image"
23+
command: |
24+
docker pull fentechai/cdt-base:latest
25+
docker build -t fentechai/cdt-test:$CIRCLE_BRANCH .
26+
docker login -u $DOCKER_USER -p $DOCKER_PASS
27+
docker push fentechai/cdt-test:$CIRCLE_BRANCH
28+
29+
test-image:
30+
docker:
31+
- image: fentechai/cdt-test:$CIRCLE_BRANCH
32+
auth:
33+
username: $DOCKER_USER
34+
password: $DOCKER_PASS
35+
steps:
36+
- checkout
37+
- setup_remote_docker
38+
- run:
39+
name: Test CDT installation
40+
no_output_timeout: 40m
41+
command: |
42+
cd /CDT && pip3 uninstall cdt -y
43+
python3 setup.py install develop --user
44+
pytest --cov-report=xml --cov=./cdt
45+
codecov --token $CODECOV_TOKEN
46+
47+
bumpversion:
48+
docker:
49+
- image: docker:17.05.0-ce-git
50+
auth:
51+
username: $DOCKER_USER
52+
password: $DOCKER_PASS
53+
steps:
54+
- checkout
55+
- setup_remote_docker
56+
- run:
57+
name: Install dependencies
58+
command: |
59+
apk add --no-cache \
60+
py-pip=9.0.0-r1
61+
apk add --no-cache bash
62+
- add_ssh_keys:
63+
fingerprints:
64+
- "94:dc:75:8a:05:8e:b6:ef:bc:34:01:ed:7d:6b:86:ee"
65+
- when:
66+
condition:
67+
equal: [ master, << pipeline.git.branch >> ]
68+
steps:
69+
- run:
70+
name: Bumpversion
71+
command: |
72+
bash ./.circleci/bumpversion.sh
73+
git config --global user.email "[email protected]"
74+
git config --global user.name "CircleCI Bumpversion"
75+
git config --global push.default simple
76+
git remote add deploy [email protected]:FenTechSolutions/CausalDiscoveryToolbox.git
77+
git add -u
78+
VERSION_NEW=$(cat setup.py| grep version | cut -c 20- | rev | cut -c 3- | rev)
79+
git commit -m "[DEPLOY] $VERSION_NEW [skip ci]"
80+
git push deploy HEAD:master
81+
82+
build-push-docker-images:
83+
parameters:
84+
base-image:
85+
type: string
86+
target-image:
87+
type: string
88+
dockerfile:
89+
type: string
90+
docker:
91+
- image: docker:17.05.0-ce-git
92+
auth:
93+
username: $DOCKER_USER
94+
password: $DOCKER_PASS
95+
steps:
96+
- checkout
97+
- setup_remote_docker
98+
- run:
99+
name: Define run environment variables
100+
command: |
101+
echo 'export COMMIT_MESSAGE="$(git log --format=%B -n 1)"' >> $BASH_ENV
102+
echo 'export SUFFIX=$SUFFIX' >> $BASH_ENV
103+
echo 'Defined VARS: SUFFIX:$SUFFIX COMMIT_MESSAGE:$COMMIT_MESSAGE'
104+
source $BASH_ENV
105+
- when:
106+
condition:
107+
equal: [ master, << pipeline.git.branch >> ]
108+
steps:
109+
- run:
110+
name: Push Docker image
111+
command: |
112+
source $BASH_ENV
113+
git pull origin master
114+
VERSION_NEW=$(cat setup.py| grep version | cut -c 20- | rev | cut -c 3- | rev)
115+
docker login -u $DOCKER_USER -p $DOCKER_PASS
116+
docker pull << parameters.base-image>>:latest
117+
docker build -f << parameters.dockerfile >> -t << parameters.target-image >>$SUFFIX:$VERSION_NEW .
118+
docker push << parameters.target-image >>$SUFFIX:$VERSION_NEW
119+
docker tag << parameters.target-image >>$SUFFIX:$VERSION_NEW << parameters.target-image >>$SUFFIX:latest
120+
docker push << parameters.target-image >>$SUFFIX:latest
121+
122+
deploy-pypi:
123+
docker:
124+
- image: docker:17.05.0-ce-git
125+
auth:
126+
username: $DOCKER_USER
127+
password: $DOCKER_PASS
128+
steps:
129+
- checkout
130+
- setup_remote_docker
131+
- when:
132+
condition:
133+
equal: [ master, << pipeline.git.branch >> ]
134+
steps:
135+
- run:
136+
name: Push to PyPi
137+
command: |
138+
git pull origin master
139+
VERSION_NEW=$(cat setup.py| grep version | cut -c 20- | rev | cut -c 3- | rev)
140+
docker pull fentechai/cdt:$VERSION_NEW
141+
docker run -e PYPI_PASSWORD=$PYPI_PASSWORD --rm fentechai/cdt:$VERSION_NEW /bin/sh -c "cd /CDT && pip3 install --upgrade keyrings.alt && pip3 install twine wheel && python3 setup.py sdist bdist_wheel && twine upload -u divkal -p '$PYPI_PASSWORD' dist/*"
142+
143+
build-docs:
144+
docker:
145+
- image: fentechai/cdt:latest
146+
auth:
147+
username: $DOCKER_USER
148+
password: $DOCKER_PASS
149+
steps:
150+
- checkout
151+
- setup_remote_docker
152+
- add_ssh_keys:
153+
fingerprints:
154+
- "94:dc:75:8a:05:8e:b6:ef:bc:34:01:ed:7d:6b:86:ee"
155+
- when:
156+
condition:
157+
equal: [ master, << pipeline.git.branch >> ]
158+
steps:
159+
- run:
160+
name: Build Docs and Push to GitHub
161+
command: |
162+
cd /CDT
163+
git pull origin master
164+
VERSION_NEW=$(cat setup.py| grep version | cut -c 20- | rev | cut -c 3- | rev)
165+
# docker pull fentechai/cdt:$VERSION_NEW
166+
git config --global user.email "[email protected]"
167+
git config --global user.name "Circle CI Docs"
168+
git config --global push.default simple
169+
# docker run -v $(pwd):/cdtlib --rm fentechai/cdt:$VERSION_NEW /bin/sh -c 'cd /cdtlib && pip3 uninstall cdt -y && pip3 install . && pip3 install sphinx recommonmark sphinxcontrib-napoleon sphinx_rtd_theme && cd docs && sphinx-build -Eab html . html'
170+
pip3 install sphinx recommonmark sphinxcontrib-napoleon sphinx_rtd_theme
171+
cd docs
172+
sphinx-build -Eab html . html
173+
git remote add deploy [email protected]:FenTechSolutions/CausalDiscoveryToolbox.git
174+
cd ..
175+
git add ./docs
176+
git commit -m "[DEPLOY] Docs $VERSION_NEW [skip ci]"
177+
git push deploy HEAD:master
178+
179+
180+
# Invoke jobs via workflows
181+
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
182+
workflows:
183+
default:
184+
jobs:
185+
- build-test:
186+
name: build-test-image
187+
188+
- test-image:
189+
name: test-image
190+
requires: [build-test-image]
191+
192+
- bumpversion:
193+
requires: [test-image]
194+
filters:
195+
branches:
196+
only:
197+
- master
198+
199+
- build-push-docker-images:
200+
name: build-cpu-image
201+
base-image: fentechai/cdt-base
202+
target-image: fentechai/cdt
203+
dockerfile: Dockerfile
204+
requires: [bumpversion]
205+
206+
- build-push-docker-images:
207+
name: build-gpu-image
208+
base-image: fentechai/nv-cdt-base
209+
target-image: fentechai/nv-cdt
210+
dockerfile: nv-Dockerfile
211+
requires: [bumpversion]
212+
213+
- deploy-pypi:
214+
requires: [build-cpu-image]
215+
- build-docs:
216+
requires: [build-cpu-image]

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- docker pull fentechai/nv-cdt-env-base:21.01
3333
- docker build --build-arg python=3.6 --build-arg spy=36 -t fentechai/cdt-dev .
3434
- if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then
35-
docker run -e CODECOV_TOKEN --rm fentechai/cdt-dev /bin/sh -c 'cd /CDT && pip3 uninstall cdt -y && python3 setup.py install develop --user && pytest --cov-report= --cov=./cdt && codecov --token $CODECOV_TOKEN';
35+
docker run -e CODECOV_TOKEN --rm fentechai/cdt-dev /bin/sh -c 'cd /CDT && pip3 uninstall cdt -y && python3 setup.py install develop --user && pytest --cov-report=xml --cov=./cdt && codecov --token $CODECOV_TOKEN';
3636
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
3737
docker push fentechai/cdt-dev;
3838
docker build -f nv-Dockerfile -t fentechai/nv-cdt-dev .;

Dockerfile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
FROM fentechai/cdt-env-base:22.02
1+
FROM fentechai/cdt-base:latest
22
MAINTAINER Diviyan Kalainathan <[email protected]>
33
LABEL description="Docker image for the Causal Discovery Toolbox"
4-
ARG python
5-
ARG spy
64

75
RUN mkdir -p /CDT
86
COPY . /CDT
97
RUN cd /CDT && \
10-
add-apt-repository ppa:deadsnakes/ppa -y && \
11-
apt-get update --allow-unauthenticated && \
12-
apt-get -q install "python${python}" "python${python}-dev" python3-pip python3-setuptools -y && \
13-
rm /usr/bin/python3 && ln -s /usr/bin/python${python} /usr/bin/python3 && \
14-
python3 -m pip install -r requirements.txt && \
8+
python3 -m pip install -r docker-requirements.txt && \
9+
python3 -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu && \
1510
python3 -m pip install pytest pytest-cov && \
1611
python3 -m pip install codecov && \
1712
python3 setup.py install

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The Causal Discovery Toolbox is a package for causal inference in graphs and in
66
[![Dev Status](https://travis-ci.org/FenTechSolutions/CausalDiscoveryToolbox.svg?branch=dev)](https://travis-ci.org/FenTechSolutions/CausalDiscoveryToolbox)
77
[![codecov](https://codecov.io/gh/FenTechSolutions/CausalDiscoveryToolbox/branch/master/graph/badge.svg)](https://codecov.io/gh/FenTechSolutions/CausalDiscoveryToolbox)
88
[![Hex.pm](https://img.shields.io/badge/License-MIT-blue.svg?maxAge=259200)](https://raw.githubusercontent.com/FenTechSolutions/CausalDiscoveryToolbox/master/LICENSE.md)
9-
[![version](https://img.shields.io/badge/version-0.5.23-yellow.svg?maxAge=259200)](#)
9+
[![version](https://img.shields.io/badge/version-0.5.24-yellow.svg?maxAge=259200)](#)
1010
![PyPI - Downloads](https://img.shields.io/pypi/dm/cdt.svg)
1111

1212
It implements lots of algorithms for graph structure recovery (including algorithms from the __bnlearn__, __pcalg__ packages), mainly based out of observational data.
@@ -25,8 +25,8 @@ Docker images are available, including all the dependencies, and enabled functio
2525

2626
| Branch | master | dev |
2727
|:----------------:|:--------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------:|
28-
| Python 3.6 - CPU | [![d36cpu](https://img.shields.io/badge/docker-0.5.23-0db7ed.svg?maxAge=259200)](https://hub.docker.com/r/fentechai/cdt/) | [![d36cpudev](https://img.shields.io/badge/docker-latest-0db7ed.svg?maxAge=259200)](https://hub.docker.com/r/fentechai/cdt-dev) |
29-
| Python 3.6 - GPU | [![d36gpu](https://img.shields.io/badge/nvidia--docker-0.5.23-76b900.svg?maxAge=259200)](https://hub.docker.com/r/fentechai/nv-cdt/) | [![d36gpudev](https://img.shields.io/badge/nvidia--docker-latest-76b900.svg?maxAge=259200)](https://hub.docker.com/r/fentechai/nv-cdt-dev) |
28+
| Python 3.6 - CPU | [![d36cpu](https://img.shields.io/badge/docker-0.5.24-0db7ed.svg?maxAge=259200)](https://hub.docker.com/r/fentechai/cdt/) | [![d36cpudev](https://img.shields.io/badge/docker-latest-0db7ed.svg?maxAge=259200)](https://hub.docker.com/r/fentechai/cdt-dev) |
29+
| Python 3.6 - GPU | [![d36gpu](https://img.shields.io/badge/nvidia--docker-0.5.24-76b900.svg?maxAge=259200)](https://hub.docker.com/r/fentechai/nv-cdt/) | [![d36gpudev](https://img.shields.io/badge/nvidia--docker-latest-76b900.svg?maxAge=259200)](https://hub.docker.com/r/fentechai/nv-cdt-dev) |
3030

3131
## Installation
3232

cdt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
from cdt.utils import loss
3333
from cdt.utils.Settings import SETTINGS
3434
from cdt.utils.R import RPackages
35-
__version__ = '0.5.23'
35+
__version__ = '0.5.24'

cdt/causality/pairwise/Jarfo_model/estimator.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,30 @@
1111
import numpy as np
1212
from sklearn import pipeline
1313
from sklearn.base import BaseEstimator
14-
from sklearn.ensemble import GradientBoostingClassifier
1514
from multiprocessing import Pool
15+
try:
16+
# For latest versions of scikit-learn
17+
from sklearn.ensemble import HistGradientBoostingClassifier as GradBoostClassifier
18+
extra_params = None
19+
20+
except ImportError:
21+
from sklearn.ensemble import GradientBoostingClassifier as GradBoostClassifier
22+
extra_params = {'n_estimators': 500,
23+
'subsample': 1.0,
24+
'min_samples_split': 8,
25+
'loss':'deviance',
26+
}
1627

1728
gbc_params = {
18-
'loss':'deviance',
1929
'learning_rate': 0.1,
20-
'n_estimators': 500,
21-
'subsample': 1.0,
22-
'min_samples_split': 8,
2330
'min_samples_leaf': 1,
2431
'max_depth': 9,
25-
'init': None,
2632
'random_state': 1,
27-
'max_features': None,
2833
'verbose': 0
2934
}
35+
if extra_params is not None:
36+
gbc_params.update(extra_params)
37+
3038

3139
selected_features = [
3240
'Adjusted Mutual Information[A,A type,B,B type]',
@@ -265,17 +273,17 @@ def __init__(self, extractor=extract_features, weights=None, symmetrize=True, nj
265273
CauseEffectEstimatorID(
266274
features_direction=self.features,
267275
features_independence=self.features,
268-
regressor=GradientBoostingClassifier,
276+
regressor=GradBoostClassifier,
269277
params=gbc_params,
270278
symmetrize=symmetrize),
271279
CauseEffectEstimatorSymmetric(
272280
features=self.features,
273-
regressor=GradientBoostingClassifier,
281+
regressor=GradBoostClassifier,
274282
params=gbc_params,
275283
symmetrize=symmetrize),
276284
CauseEffectEstimatorOneStep(
277285
features=self.features,
278-
regressor=GradientBoostingClassifier,
286+
regressor=GradBoostClassifier,
279287
params=gbc_params,
280288
symmetrize=symmetrize),
281289
]

0 commit comments

Comments
 (0)