Skip to content

Commit

Permalink
Merge pull request #25 from NREL/develop
Browse files Browse the repository at this point in the history
alfalfa-client 0.2.0
  • Loading branch information
TShapinsky authored Apr 14, 2022
2 parents 876b4cb + a3ebd00 commit 2ff4196
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 225 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.6'

- name: Run pre-commit
uses: pre-commit/action@v2.0.0
with:
extra_args: --all-files
- name: Checkout code
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.6"

- name: Run pre-commit
uses: pre-commit/action@v2.0.0
with:
extra_args: --all-files
tests:
name: Run tests
runs-on: ubuntu-latest
Expand All @@ -33,12 +33,12 @@ jobs:
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.6'
python-version: "3.6"

- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: '1.1.2'
poetry-version: "1.1.2"

- name: Run tests with poetry and pytest
run: |
Expand Down
43 changes: 34 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
args: ['--maxkb=50000']
args: ["--maxkb=50000"]
- id: check-ast
- id: check-json
- id: check-merge-conflict
Expand All @@ -14,19 +14,44 @@ repos:
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: mixed-line-ending
args: ['--fix=auto']
args: ["--fix=auto"]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.4
rev: v1.6.0
hooks:
- id: autopep8
args: ['--in-place', '--aggressive', '--aggressive', '--recursive', '--max-line-length=100', '--ignore=E501,E402,W503,W504,E731']
args:
[
"--in-place",
"--aggressive",
"--aggressive",
"--recursive",
"--max-line-length=100",
"--ignore=E501,E402,W503,W504,E731",
]
- repo: https://github.com/humitos/mirrors-autoflake.git
rev: v1.3
hooks:
- id: autoflake
args: ['--in-place', '--recursive', '--remove-all-unused-imports', '--remove-unused-variable', '--ignore-init-module-imports']
args:
[
"--in-place",
"--recursive",
"--remove-all-unused-imports",
"--remove-unused-variable",
"--ignore-init-module-imports",
]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 4.0.1
hooks:
- id: flake8
args: ['--ignore=E501,E402,W503,W504,E731,F401']
args: ["--ignore=E501,E402,W503,W504,E731,F401"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
- id: prettier
types_or: [css, yaml, markdown, json, html, scss, javascript]
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
args: ["-m=VERTICAL_HANGING_INDENT"] # vertical hanging
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

v0.2.0 (Unreleased)
------
* Rename graphQL endpoint from osmName to modelName. This is a breaking change.

v0.1.1
------
* Fix the exteralClock to allow passing either a boolean or a string
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Alfalfa Client

The purpose of this repository is to provide a standalone client for use with the Alfalfa application. It additionally includes a Historian to quickly/easily enable saving of results from Alfalfa simulations.
The purpose of this repository is to provide a standalone client for use with the Alfalfa application. It additionally includes a Historian to quickly/easily enable saving of results from Alfalfa simulations.

# Usage

Expand All @@ -19,13 +19,16 @@ historian = ah.Historian
```

# Setup and Testing

This repository is setup to use:

- [pyenv](https://github.com/pyenv/pyenv#installation) for managing python versions
- [poetry](https://python-poetry.org/docs/#installation) for managing environment
- [pre-commit](https://pre-commit.com/#install) for managing code styling
- tox for running tests in isolated build environments. See the expected python versions in [tox.ini](./tox.ini)
- tox for running tests in isolated build environments. See the expected python versions in [tox.ini](./tox.ini)

Assuming poetry is installed and the necessary python versions are installed, the following should exit cleanly:

```bash
git clone https://github.com/NREL/alfalfa-client.git
cd alfalfa-client
Expand All @@ -36,9 +39,18 @@ This may take some time resolving on the initial run, but subsequent runs should

See [this gist](https://gist.github.com/corymosiman12/26fb682df2d36b5c9155f344eccbe404) for additional info.


# History
- The implemented client is previously referred to as Boptest, from the alfalfa/client/boptest.py implementation. It has been ported as a standalone package for easier usage across projects.

- The implemented client is previously referred to as Boptest, from the alfalfa/client/boptest.py implementation. It has been ported as a standalone package for easier usage across projects.

# Releasing
See [release info here](https://gist.github.com/corymosiman12/26fb682df2d36b5c9155f344eccbe404#releasing)

1. Merge all branches into develop, make sure tests pass
1. Update the version (assume version is 0.1.2): `poetry version 0.1.2`
1. Update the version test file (i.e. my-repo/tests/test_version.py) to match the above version
1. Make sure tests pass: `poetry run tox`
1. Merge develop into main (previously, master), make sure tests pass
1. Create a tag: `git tag 0.1.2`
1. Build: `poetry build`
1. Publish `poetry publish` (this will push to pypi)
1. Create a new release on the Github repository using the tag and link to PyPI
12 changes: 10 additions & 2 deletions alfalfa_client/alfalfa_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@
****************************************************************************************************
"""

import json
from multiprocessing import Pool

import json
import requests

from alfalfa_client.lib import convert, process_haystack_rows, start_one, status, stop_one, submit_one, wait
from alfalfa_client.lib import (
convert,
process_haystack_rows,
start_one,
status,
stop_one,
submit_one,
wait
)


class AlfalfaClient:
Expand Down
1 change: 1 addition & 0 deletions alfalfa_client/historian.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# Credit: Nicholas Long

import os

import pandas as pd


Expand Down
8 changes: 4 additions & 4 deletions alfalfa_client/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
****************************************************************************************************
"""

from collections import OrderedDict

import json
import os
import requests
import time
import uuid
from collections import OrderedDict

import requests
from requests_toolbelt import MultipartEncoder


Expand Down Expand Up @@ -131,7 +131,7 @@ def submit_one(args):

# After the file has been uploaded, then tell BOPTEST to process the site
# This is done not via the haystack api, but through a graphql api
mutation = 'mutation { addSite(osmName: "%s", uploadID: "%s") }' % (filename, uid)
mutation = 'mutation { addSite(modelName: "%s", uploadID: "%s") }' % (filename, uid)
for _ in range(3):
response = requests.post(url + '/graphql', json={'query': mutation})
if response.status_code == 200:
Expand Down
Loading

0 comments on commit 2ff4196

Please # to comment.