Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #296 #297

Merged
merged 21 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/python-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.10'

- uses: actions/cache@v2
with:
Expand All @@ -38,11 +38,11 @@ jobs:
- name: Test with pytest
run: |
coverage run -m pytest --cov-config=.coveragerc
- name: Debug coverage
run: coverage report -m

- name: Convert to LCO
run: coverage lcov --rcfile=.coveragerc

- name: Upload coverage data to coveralls.io
run: coveralls --service=github --rcfile=.coveragerc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/python-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ on:
jobs:
deploy:

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.10'

- uses: actions/cache@v2
with:
Expand All @@ -28,7 +28,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e .[s3,tune]
pip install -r ./requirements/DEV_REQUIREMENTS.txt

pip install -r ./requirements/S3_REQUIREMENTS.txt
pip install -r ./requirements/TUNE_REQUIREMENTS.txt
pip install -r ./requirements/TEST_EXTRAS_REQUIREMENTS.txt
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/python-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ on:
jobs:
run_lint:

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.10'

- uses: actions/cache@v2
with:
Expand All @@ -37,8 +37,8 @@ jobs:

- name: Run isort linter
run: |
isort --check . --skip="debug" --skip="versioneer.py" --skip="tests" --skip="_version.py"
isort --check .

- name: Run black linter
run: |
black --check . --exclude="versioneer.py|_version.py|debug|tests"
black --check .
4 changes: 2 additions & 2 deletions .github/workflows/python-manual-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ on: workflow_dispatch
jobs:
deploy:

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.10'

- uses: actions/cache@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
deploy:

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-pytest-s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-pytest-tune.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-test-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ on:
jobs:
deploy:

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.10'

- uses: actions/cache@v2
with:
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</p>

<p align="center">
<a><img src="https://img.shields.io/badge/python-3.6+-informational.svg"/></a>
<a><img src="https://img.shields.io/badge/python-3.7+-informational.svg"/></a>
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg"/></a>
<a href="https://badge.fury.io/py/spock-config"><img src="https://badge.fury.io/py/spock-config.svg"/></a>
<a href="https://pepy.tech/project/spock-config"><img src="https://static.pepy.tech/personalized-badge/spock-config?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads"/></a>
Expand Down Expand Up @@ -84,7 +84,7 @@ generating CLI arguments, and hierarchical configuration by composition.

## Quick Install

The basic install and `[s3]` extension require Python 3.6+ while the `[tune]` extension requires Python 3.7+
The basic install and `[s3]` extension require Python 3.7+ while the `[tune]` extension requires Python 3.8+

| Base | w/ S3 Extension | w/ Hyper-Parameter Tuner |
|------|-----------------|--------------------------|
Expand All @@ -102,7 +102,11 @@ See [Releases](https://github.com/fidelity/spock/releases) for more information.

<details>

### Jan 12th, 2023
#### August 30th, 2023
* Removed Python 3.6 support as it was causing dependency hell
* Collection of bugfixes

#### Jan 12th, 2023
* Added support for resolving value definitions from references to other defined variables with the following syntax,`${spock.var:SpockClass.defined_variable}`
* Added support for new fundamental types: (1) file: this is an overload of a str that verifies file existence and (r/w) access (2) directory: this is an overload of a str that verifies directory existence, creation if not existing, and (r/w) access
* Deprecated support for `List` of repeated `@spock` decorated classes.
Expand Down
8 changes: 5 additions & 3 deletions REQUIREMENTS.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
attrs~=21.4
attrs~=23.1
cryptography~=37.0
GitPython~=3.1
pytomlpp~=1.0
pyYAML~=5.4
setuptools~=59.6
# pyYAML~=5.4
pyYAML~=6.0
setuptools~=68.1 ; python_version >= '3.8'
setuptools~=68.0 ; python_version == '3.7'
25 changes: 13 additions & 12 deletions requirements/DEV_REQUIREMENTS.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
black~=22.1 ; python_version >= '3.7'
black~=21.4b0 ; python_version == '3.6'
coveralls~=3.3
coverage[toml]~=6.1
isort~=5.10
black~=23.7 ; python_version >= '3.8'
black~=23.3 ; python_version == '3.7'
# coveralls~=3.3
coverage[toml]~=7.3 ; python_version >= '3.8'
coverage[toml]~=7.2 ; python_version == '3.7'
isort~=5.12 ; python_version >= '3.8'
isort~=5.11 ; python_version == '3.7'
moto~=3.1
pre-commit~=2.20 ; python_version >= '3.7'
pre-commit~=2.17 ; python_version == '3.6'
pydoc-markdown~=4.3, < 4.6.* ; python_version >= '3.7'
pydoc-markdown~=3.13 ; python_version == '3.6'
pytest~=7.0
pytest-cov~=3.0
pylint~=2.11
pre-commit~=3.3 ; python_version >= '3.8'
pre-commit~=2.21 ; python_version == '3.7'
pydoc-markdown~=4.8 ; python_version >= '3.7'
pytest~=7.4 ; python_version >= '3.7'
pytest-cov~=4.1 ; python_version >= '3.7'
pylint~=2.17 ; python_version >= '3.7'
6 changes: 3 additions & 3 deletions requirements/S3_REQUIREMENTS.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
boto3~=1.20
botocore~=1.26
boto3~=1.28 ; python_version >= '3.7'
botocore~=1.31 ; python_version >= '3.7'
hurry.filesize~=0.9
s3transfer~=0.5
s3transfer~=0.6 ; python_version >= '3.7'
9 changes: 6 additions & 3 deletions requirements/TUNE_REQUIREMENTS.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
mypy_extensions~=0.4; python_version < '3.8'
optuna~=2.10
torch>=1.8.1
ax-platform~=0.2.4; python_version >= '3.7'
optuna~=3.3
torch~=2.0 ; python_version >= '3.8'
torch~=1.13 ; python_version <= '3.7'
ax-platform~=0.3.4; python_version >= '3.9'
ax-platform~=0.3.3; python_version == '3.8'

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"": ["py.typed", "*.pyi"],
},
include_package_data=True,
python_requires=">=3.6",
python_requires=">=3.7",
install_requires=install_reqs,
extras_require={"s3": s3_reqs, "tune": tune_reqs},
)
30 changes: 16 additions & 14 deletions spock/backend/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,22 @@ def handle_attributes_print(info_dict, max_indent: int):
max_indent: max indent for pretty print of help

"""
# Figure out indents
max_param_length = max([len(k) for k in info_dict.keys()])
max_type_length = max([v["len"]["type"] for v in info_dict.values()])
# Print akin to the argparser
for k, v in info_dict.items():
print(
f" {k}"
+ (" " * (max_param_length - v["len"]["name"] + max_indent))
+ f'{v["type"]}'
+ (" " * (max_type_length - v["len"]["type"] + max_indent))
+ f'{v["desc"]} {v["default"]}'
)
# Blank for spacing :-/
print("")
# Add check for an empty dict (corresponds to any empty spock class)
if len(info_dict) > 0:
# Figure out indents
max_param_length = max([len(k) for k in info_dict.keys()])
max_type_length = max([v["len"]["type"] for v in info_dict.values()])
# Print akin to the argparser
for k, v in info_dict.items():
print(
f" {k}"
+ (" " * (max_param_length - v["len"]["name"] + max_indent))
+ f'{v["type"]}'
+ (" " * (max_type_length - v["len"]["type"] + max_indent))
+ f'{v["desc"]} {v["default"]}'
)
# Blank for spacing :-/
print("")


def get_type_string(val, nested_others):
Expand Down
1 change: 0 additions & 1 deletion spock/backend/typed.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def _recursive_generic_validator(typed):
# Iterate through since there might be multiple types?
# Handle Tuple type
if _get_name_py_version(typed) == "Tuple":

# Tuples by def have len more than 1. We throw an exception if not since
# a tuple is not necessary in that case. Tuples can also have mixed types,
# thus we need to handle this oddity here -- we do this by passing each
Expand Down
1 change: 0 additions & 1 deletion spock/backend/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ def __call__(
validator(inst, attr, member)

def __repr__(self):

return (
f"<ordered is instance deep_iterable validator for types "
f"{self.ordered_types}>"
Expand Down
1 change: 0 additions & 1 deletion spock/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def _build(self) -> Dict:


class SelfGraph(BaseGraph):

var_resolver = VarResolver()

def __init__(self, cls: _C, fields: Dict):
Expand Down
5 changes: 5 additions & 0 deletions spock/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,13 +602,15 @@ def add_repo_info(out_dict: Dict) -> Dict:
head_result = subprocess.run(
"git rev-parse --abbrev-ref --symbolic-full-name HEAD",
stdout=subprocess.PIPE,
stdin=subprocess.DEVNULL if sys.platform == "win32" else None,
shell=True,
check=False,
)
else:
head_result = subprocess.run(
"git rev-parse --abbrev-ref --symbolic-full-name HEAD",
capture_output=True,
stdin=subprocess.DEVNULL if sys.platform == "win32" else None,
shell=True,
check=False,
)
Expand All @@ -631,6 +633,9 @@ def add_repo_info(out_dict: Dict) -> Dict:
out_dict.update(
{"# Git Origin": repo.active_branch.commit.repo.remotes.origin.url}
)
# Attempt to close to not leak resources
# https://github.com/gitpython-developers/GitPython#leakage-of-system-resources
repo.close()
except git.InvalidGitRepositoryError: # pragma: no cover
# But it's okay if we are not
out_dict = make_blank_git(out_dict)
Expand Down
Loading