Skip to content

Commit

Permalink
added version update to cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
AyrtonB committed Mar 27, 2021
1 parent 4228f1e commit 1d1377d
Show file tree
Hide file tree
Showing 5 changed files with 434 additions and 3 deletions.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- statsmodels
- scikit-learn
- scikit-optimize
- typer
- pip

- pip:
Expand Down
9 changes: 7 additions & 2 deletions moepy/_nbdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@
"construct_df_pred": "05-price-moe.ipynb",
"calc_error_metrics": "05-price-moe.ipynb",
"get_model_pred_ts": "05-price-moe.ipynb",
"weighted_mean_s": "05-price-moe.ipynb"}
"weighted_mean_s": "05-price-moe.ipynb",
"app": "10-ci-cd.ipynb",
"get_current_package_version": "10-ci-cd.ipynb",
"increment_package_version": "10-ci-cd.ipynb",
"set_current_package_version": "10-ci-cd.ipynb"}

modules = ["retrieval.py",
"eda.py",
"lowess.py",
"surface.py",
"moe.py"]
"moe.py",
"cicd.py"]

doc_url = "https://AyrtonB.github.io/Merit-Order-Effect/"

Expand Down
64 changes: 64 additions & 0 deletions moepy/cicd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/10-ci-cd.ipynb (unless otherwise specified).

__all__ = ['app', 'get_current_package_version', 'increment_package_version', 'set_current_package_version']

# Cell
import os
import re
import typer
import logging
from warnings import warn
from configparser import ConfigParser

# Cell
app = typer.Typer()

# Cell
@app.command()
def get_current_package_version(settings_fp: str='settings.ini'):
config = ConfigParser(delimiters=['='])
config.read(settings_fp)
version = config.get('DEFAULT', 'version')

return version

# Cell
@app.command()
def increment_package_version(old_version: str, increment_level: str='micro'):
increment = lambda rev: str(int(rev)+1)

major, minor, micro = old_version.split('.') # naming from - https://the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/specification.html#sequence-based-scheme

if increment_level == 'major':
major = increment(major)
elif increment_level == 'minor':
minor = increment(minor)
elif increment_level == 'micro':
micro = increment(micro)

new_version = '.'.join([major, minor, micro])

return new_version

# Cell
@app.command()
def set_current_package_version(version: str, settings_fp: str='settings.ini'):
version = version.replace('v', '')

config = ConfigParser(delimiters=['='])
config.read(settings_fp)

config.set('DEFAULT', 'version', version)

with open(settings_fp, 'w') as configfile:
config.write(configfile)

logger = logging.getLogger('package_release')
logger.setLevel('INFO')
logger.info(f'The package version has to be updated to {version}')

return

# Cell
if __name__ == '__main__' and '__file__' in globals():
app()
Loading

0 comments on commit 1d1377d

Please sign in to comment.