Skip to content

Commit 9857da1

Browse files
calad0ivloncarJanFSchulte
authored
Lazy converter imports and migrate to pyproject.toml (fastmachinelearning#1094)
* import converter dependencies lazily * make tf and qkeras optionl, stop assuming keras is tf.keras * less mandatory dependency * fix dsp_aware_pruning test import path * fix broken setup.cfg after rebase, rm pyparsing * purge qkeras workaround * switch to pyproject.toml switch to pyproject.toml include pyproject.toml after install * format * rm useless flake8 config in pyprject.toml * Add hint on import failure * leftover * rm setup.py from manifest * manifest fix 2 * move contrib * bump HGQ req. ver * incl. all in hls4ml/contrib in sdist * remove excess @requires, update hgq dep flag * style fix * use dynamic version * Use the cli as a python module instead of hardcoded path * It's called "quartus" not "quantus" * It's called "quartus" not "quantus" part2 * Forgot to commit the __main__ of cli * Import numerical instead of using a full name --------- Co-authored-by: Vladimir Loncar <[email protected]> Co-authored-by: Jan-Frederik Schulte <[email protected]>
1 parent 1ad1ad9 commit 9857da1

38 files changed

+285
-228
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ repos:
99
args: ['--line-length=125',
1010
'--skip-string-normalization']
1111

12+
- repo: https://github.com/tox-dev/pyproject-fmt
13+
rev: v2.5.0
14+
hooks:
15+
- id: pyproject-fmt
16+
1217
- repo: https://github.com/pre-commit/pre-commit-hooks
1318
rev: v5.0.0
1419
hooks:
1520
- id: check-added-large-files
1621
- id: check-case-conflict
1722
- id: check-merge-conflict
1823
- id: check-symlinks
24+
- id: check-toml
1925
- id: check-yaml
2026
- id: debug-statements
2127
- id: end-of-file-fixer
@@ -27,19 +33,13 @@ repos:
2733
rev: 5.13.2
2834
hooks:
2935
- id: isort
30-
args: ["--profile", "black", --line-length=125]
3136

3237
- repo: https://github.com/asottile/pyupgrade
3338
rev: v3.19.1
3439
hooks:
3540
- id: pyupgrade
3641
args: ["--py36-plus"]
3742

38-
- repo: https://github.com/asottile/setup-cfg-fmt
39-
rev: v2.7.0
40-
hooks:
41-
- id: setup-cfg-fmt
42-
4343
- repo: https://github.com/pycqa/flake8
4444
rev: 7.1.1
4545
hooks:

MANIFEST.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
include LICENSE README.md CONTRIBUTING.md CITATION.cff pyproject.toml setup.py setup.cfg .clang-format
1+
include LICENSE README.md CONTRIBUTING.md CITATION.cff pyproject.toml .clang-format
22
graft example-models
33
graft test
44
graft contrib
55
recursive-include hls4ml/templates *
6-
global-exclude .git .gitmodules .gitlab-ci.yml
6+
recursive-include hls4ml *.py
7+
recursive-include hls4ml/contrib *
8+
global-exclude .git .gitmodules .gitlab-ci.yml *.pyc
79
include hls4ml/backends/vivado_accelerator/supported_boards.json

hls4ml/__init__.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
# Temporary workaround for QKeras installation requirement, will be removed after 1.0.0
2-
def maybe_install_qkeras():
3-
import subprocess
4-
import sys
5-
6-
QKERAS_PKG_NAME = 'QKeras'
7-
# QKERAS_PKG_SOURCE = QKERAS_PKG_NAME
8-
QKERAS_PKG_SOURCE = 'qkeras@git+https://github.com/fastmachinelearning/qkeras.git'
9-
10-
def pip_list():
11-
p = subprocess.run([sys.executable, '-m', 'pip', 'list'], check=True, capture_output=True)
12-
return p.stdout.decode()
13-
14-
def pip_install(package):
15-
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
16-
17-
all_pkgs = pip_list()
18-
if QKERAS_PKG_NAME not in all_pkgs:
19-
print('QKeras installation not found, installing one...')
20-
pip_install(QKERAS_PKG_SOURCE)
21-
print('QKeras installed.')
22-
23-
24-
try:
25-
maybe_install_qkeras()
26-
except Exception:
27-
print('Could not find QKeras installation, make sure you have QKeras installed.')
28-
29-
# End of workaround
30-
311
from hls4ml import converters, report, utils # noqa: F401, E402
322

333
try:
File renamed without changes.

hls4ml/cli/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import main
2+
3+
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)