Skip to content

Commit

Permalink
Merge pull request #1 from knikolla/master
Browse files Browse the repository at this point in the history
  • Loading branch information
larsks authored May 24, 2024
2 parents 458b580 + 69ab371 commit fd2eb3b
Show file tree
Hide file tree
Showing 12 changed files with 513 additions and 19 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Unit tests
on:
push:
pull_request:

jobs:
run-unit-tests:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: |
pip install -e .
pip install -r test-requirements.txt
- name: Run unit tests
run: |
pytest src/nerc_rates/tests
162 changes: 162 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# moc-templates

This repository serves two purposes:

- It may be used as a template repository when creating new repositories in the [CCI-MOC][] organization.
- It is the canonical location of the `LICENSE` and `CONTRIBUTING.md` files.

[cci-moc]: https://github.com/CCI-MOC/

## Contributing

We'd love to have you contribute! Please refer to our [contribution
guidelines](CONTRIBUTING.md) for details.

## License

[Apache 2.0 License](LICENSE).

The code is provided as-is with no warranties.
# NERC Rates
This repository stores rates and invoicing configuration for the New England
Research Cloud.

The values are stored in `rates.yaml` as a list with each item under the
following format. Each item in the list contains a `name` and `history`.
`history` is itself a list containing `value` (required), `from` (required),
and `until` (optional).

```yaml
- name: CPU SU Rate
history:
- value: 0.013
from: 2023-06
until: 2024-06
- value: 0.15
from: 2024-07
```
To make use of the rates, install the package and import the module
```python
from nerc_rates import load_from_url
rates = load_from_url()
rates.get_value_at("CPU SU Rate", "2024-06")
```
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
name = "nerc_rates"
authors = [
{name="MOC Alliance"},
]
version = "0.1"
readme = "README.md"
classifiers = [
"Programming Language :: Python :: 3"
]
requires-python = ">=3.8"
dependencies = [
"pydantic",
"pyyaml",
"requests",
]

[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"

[tool.setuptools.package-dir]
"" = "src"
56 changes: 56 additions & 0 deletions rates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#################################################
# Service Unit Rates
#################################################
- name: CPU SU Rate
history:
- value: "0.013"
from: 2023-06

- name: GPUA100 SU Rate
history:
- value: "1.803"
from: 2023-06

- name: GPUA100SXM4 SU Rate
history:
- value: "2.078"
from: 2023-06

- name: GPUV100 SU Rate
history:
- value: "1.214"
from: 2023-06

- name: GPUK80 SU Rate
history:
- value: "0.463"
from: 2023-06

- name: Storage GB Rate
history:
- value: "0.000009"
from: 2023-06

#################################################
# Feature Flags
#################################################
- name: Charge for Stopped Instances
history:
- value: "False"
from: 2023-06
until: 2024-02
- value: "True"
from: 2024-03

#################################################
# SU Definitions
#################################################
- name: vCPUs in CPU SU
history:
- value: "1"
from: 2023-06

- name: RAM in CPU SU
history:
- value: "4096"
from: 2023-06
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pydantic
pyyaml
requests
1 change: 1 addition & 0 deletions src/nerc_rates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from nerc_rates.rates import load_from_file, load_from_url
Loading

0 comments on commit fd2eb3b

Please sign in to comment.