diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml new file mode 100644 index 00000000..0041913b --- /dev/null +++ b/.github/workflows/pypi.yaml @@ -0,0 +1,27 @@ +# Setting up github action for pypi + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* + diff --git a/requirements.txt b/requirements.txt index 59270460..b88e7542 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,28 +1,19 @@ +###### Requirements without Version Specifiers ###### +iminuit +lightgbm +scikit-learn +seaborn +setuptools_scm + +###### Requirements with Version Specifiers ###### astropy>=1.1.2 -jupyter>=1.0.0 +future>=0.16 +george>=0.3.0 matplotlib>=1.5.1 +nose>=1.3.7 numpy>=1.18.4 -scikit-learn>=0.20.0 -scipy>=0.17.0 -george>=0.3.0 -iminuit>=1.2 pandas>=0.23.0 -extinction>=0.3.0 -imbalanced-learn>=0.4.3 -# python==3.7 -pip>=20.1 -emcee>=2.1.0 -numpydoc>=0.6.0 -pytest-remotedata>=0.3.1 +pyyaml>=3.13 pywavelets>=0.4.0 +scipy>=0.17.0 sncosmo>=2.1.0 -nose>=1.3.7 -future>=0.16 -pyyaml>=3.13 -pytest-xdist>=1.26.1 -seaborn -schwimmbad -# cesium -tqdm -lightgbm -ipympl \ No newline at end of file diff --git a/setup.py b/setup.py index e06756c2..61e9d149 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup +from setuptools import setup, find_packages from setuptools.command.install import install import sys import os @@ -7,7 +7,7 @@ PACKAGENAME = 'snmachine' -__FALLBACK_VERSION__ = '2.0.0' +__FALLBACK_VERSION__ = '2.1.0' class ExtractExampleData(install): @@ -37,22 +37,40 @@ def run(self): setup( name='snmachine', + author='Michelle Lochner et al.', + author_email='dr.michelle.lochner@gmail.com', + description='Machine learning code for photometric supernova ' + 'classification', + url='https://github.com/LSSTDESC/snmachine', + license='BSD-3-Clause License', + description='Machine learning code for photometric supernova ' + 'classification', use_scm_version={ "root": ".", "relative_to": __file__, "fallback_version": __FALLBACK_VERSION__}, setup_requires=['setuptools_scm>=3.2.0'], - packages=['snmachine', 'utils'], + packages=find_packages(), include_package_data=True, package_data={'snmachine': ['example_data/SPCC_SUBSET.tar.gz', 'example_data/output_spcc_no_z/features/*.dat', 'example_data/example_data_for_tests.pckl']}, exclude_package_data={'utils': ['archive/*']}, cmdclass={'install': ExtractExampleData}, - url='https://github.com/LSSTDESC/snmachine', - license='BSD-3-Clause License', - author='Michelle Lochner et al.', - author_email='dr.michelle.lochner@gmail.com', - description='Machine learning code for photometric supernova ' - 'classification' + install_requires=['astropy>=1.1.2', + 'matplotlib>=3.0.0', + 'numpy>=1.18.4', + 'scikit-learn', + 'scipy>=1.4.0', + 'george>=0.3.0', + 'iminuit', + 'pandas>=0.23.0', + 'pywavelets>=0.4.0', + 'sncosmo>=2.1.0', + 'nose>=1.3.7', + 'future>=0.16', + 'pyyaml>=3.13', + 'seaborn', + 'lightgbm', + 'setuptools_scm'] ) diff --git a/snmachine/snclassifier.py b/snmachine/snclassifier.py index b1d670b5..a7eb9a1a 100644 --- a/snmachine/snclassifier.py +++ b/snmachine/snclassifier.py @@ -27,7 +27,7 @@ from sklearn import model_selection from sklearn.model_selection import PredefinedSplit, StratifiedKFold from sklearn.preprocessing import StandardScaler -from utils import plasticc_utils +from snmachine.utils import plasticc_utils # This allows the user to easily loop through all possible classifiers choice_of_classifiers = ['svm', 'knn', 'random_forest', 'decision_tree', diff --git a/utils/__init__.py b/snmachine/utils/__init__.py similarity index 100% rename from utils/__init__.py rename to snmachine/utils/__init__.py diff --git a/utils/config.yml b/snmachine/utils/config.yml similarity index 100% rename from utils/config.yml rename to snmachine/utils/config.yml diff --git a/utils/imblearn_augment.py b/snmachine/utils/imblearn_augment.py similarity index 100% rename from utils/imblearn_augment.py rename to snmachine/utils/imblearn_augment.py diff --git a/snmachine/utils/plasticc_feature_engineering.py b/snmachine/utils/plasticc_feature_engineering.py new file mode 100644 index 00000000..e69de29b diff --git a/snmachine/utils/plasticc_make_predictions.py b/snmachine/utils/plasticc_make_predictions.py new file mode 100644 index 00000000..e69de29b diff --git a/utils/plasticc_pipeline.py b/snmachine/utils/plasticc_pipeline.py similarity index 98% rename from utils/plasticc_pipeline.py rename to snmachine/utils/plasticc_pipeline.py index c5ddee87..5a16d244 100755 --- a/utils/plasticc_pipeline.py +++ b/snmachine/utils/plasticc_pipeline.py @@ -24,11 +24,10 @@ from argparse import ArgumentParser # not used at the moment -from imblearn.metrics import classification_report_imbalanced -# from imblearn.over_sampling import SMOTE -from imblearn.pipeline import make_pipeline -# from utils.plasticc_utils import plasticc_log_loss -from utils.plasticc_utils import plot_confusion_matrix +#from imblearn.metrics import classification_report_imbalanced +#from imblearn.over_sampling import SMOTE +#from imblearn.pipeline import make_pipeline +from snmachine.utils.plasticc_utils import plot_confusion_matrix from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split diff --git a/utils/plasticc_utils.py b/snmachine/utils/plasticc_utils.py similarity index 100% rename from utils/plasticc_utils.py rename to snmachine/utils/plasticc_utils.py