Skip to content

Commit 75c1877

Browse files
committed
More debug output and code reformat
1 parent 92364fd commit 75c1877

12 files changed

+127
-52
lines changed

.github/workflows/tests.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,38 @@ jobs:
2323

2424
- name: Install Dependencies (Pure Python)
2525
if: ${{ !matrix.cython }}
26-
run: poetry install --without dev,docs
26+
run: |
27+
poetry install --without dev,docs
28+
poetry run python -c "import sys; print('Python version:', sys.version)"
29+
poetry run python -c "import iscc_core; print('iscc_core version:', iscc_core.__version__)"
2730
2831
- name: Install Dependencies (with Cython)
2932
if: ${{ matrix.cython }}
30-
run: poetry install --without dev,docs --extras cython
33+
run: |
34+
poetry install --without dev,docs --extras cython
35+
poetry run python -c "import sys; print('Python version:', sys.version)"
36+
poetry run python -c "import iscc_core; print('iscc_core version:', iscc_core.__version__)"
37+
poetry run python -c "import iscc_core; print('Using Cython:', iscc_core.USING_CYTHON)"
38+
poetry run python -c "import iscc_core; print('iscc_core file:', iscc_core.__file__)"
39+
poetry run python -c "import iscc_core.cdc; print('cdc module:', iscc_core.cdc.__file__)"
3140
3241
- name: Run Tests
3342
run: |
3443
poetry run python -c "import iscc_core; print(f'Using Cython: {iscc_core.USING_CYTHON}')"
3544
poetry run pytest -v tests
3645
46+
- name: Debug Info
47+
if: failure()
48+
run: |
49+
echo "Current directory:"
50+
pwd
51+
echo "Directory contents:"
52+
ls -R
53+
echo "Python version:"
54+
python --version
55+
echo "Pip list:"
56+
pip list
57+
3758
- name: Upload coverage to Codecov
3859
uses: codecov/codecov-action@v3
3960
if: matrix.os == 'ubuntu-20.04' && matrix.python-version == '3.9' && !matrix.cython

build.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# -*- coding: utf-8 -*-
2-
import os
32
from setuptools import Extension
43

54

5+
import os
6+
import sys
7+
8+
69
def build(setup_kwargs):
10+
print(f"Python version: {sys.version}")
11+
print(f"Current working directory: {os.getcwd()}")
12+
print(f"Contents of current directory: {os.listdir('.')}")
13+
print(f"Contents of iscc_core directory: {os.listdir('iscc_core')}")
14+
715
try:
816
from Cython.Build import cythonize
917

@@ -36,7 +44,4 @@ def build(setup_kwargs):
3644
else:
3745
print("Cython not available, using pure Python")
3846

39-
print(f"Current working directory: {os.getcwd()}")
40-
print(f"Contents of current directory: {os.listdir('.')}")
41-
print(f"Contents of iscc_core directory: {os.listdir('iscc_core')}")
4247
print(f"Setup kwargs: {setup_kwargs}")

iscc_core/__init__.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import sys
22

33

4-
def _using_cython_modules():
4+
def _using_cython_modules(): # pragma: no cover
55
modules = ["cdc", "minhash", "simhash", "dct", "wtahash"]
6-
return any(
7-
getattr(sys.modules.get(f"iscc_core.{module}"), "__file__", "").endswith((".so", ".pyd"))
8-
for module in modules
9-
)
6+
cython_modules = []
7+
for module in modules:
8+
module_path = getattr(sys.modules.get(f"iscc_core.{module}"), "__file__", "")
9+
if module_path.endswith((".so", ".pyd")):
10+
cython_modules.append(module)
11+
print(f"Module {module} path: {module_path}")
12+
print(f"Cython modules: {cython_modules}")
13+
return bool(cython_modules)
1014

1115

1216
USING_CYTHON = _using_cython_modules()
17+
print(f"USING_CYTHON: {USING_CYTHON}")
1318

1419
__version__ = "1.1.0"
1520
from iscc_core.options import core_opts, conformant_options

iscc_core/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def type_id(self) -> str:
118118
length = "".join([t.name[0] for t in mtypes]) + "DI"
119119
else:
120120
length = self.length
121-
return f"{self.maintype.name}-" f"{self.subtype.name}-" f"{self.version.name}-" f"{length}"
121+
return f"{self.maintype.name}-{self.subtype.name}-{self.version.name}-{length}"
122122

123123
@property
124124
def explain(self) -> str:

poetry.lock

+53-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+6-4
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ pytest-cov = "*"
6666

6767
[tool.poetry.group.dev.dependencies]
6868
poethepoet = "*"
69-
black = "^23.1"
70-
bandit = "^1.7"
69+
black = "*"
70+
ruff = "*"
71+
bandit = "*"
7172

7273
[tool.poetry.group.docs.dependencies]
7374
mkdocs-material = "^9.0"
@@ -78,9 +79,10 @@ mdformat_tables = "*"
7879
griffe = "<0.27.4"
7980

8081
[tool.black]
81-
skip-string-normalization = false
8282
line-length = 100
83-
target-version = ['py37']
83+
preview = true
84+
enable-unstable-feature = ["string_processing"]
85+
target-version = ['py39']
8486

8587
[tool.poe.tasks]
8688
gentests = { cmd = "poetry run python -m tests.build_test_data", help = "Generate conformance test data" }

tests/build_docs.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Copy README.md to documentation index.md"""
2+
23
from os.path import abspath, dirname, join
34

45

@@ -13,9 +14,18 @@ def main():
1314
"""Copy root files to documentation site."""
1415
with open(SRC, "rt", encoding="utf-8") as infile:
1516
text = infile.read()
16-
m = "![ISCC Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-light.png)\n"
17-
r1 = "![ISCC Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-light.png#only-light)\n"
18-
r2 = "![ISCC Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-dark.png#only-dark)\n"
17+
m = (
18+
"![ISCC"
19+
" Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-light.png)\n"
20+
)
21+
r1 = (
22+
"![ISCC"
23+
" Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-light.png#only-light)\n"
24+
)
25+
r2 = (
26+
"![ISCC"
27+
" Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-dark.png#only-dark)\n"
28+
)
1929
text = text.replace(m, r1 + r2)
2030
with open(DST, "wt", encoding="utf-8", newline="\n") as outf:
2131
outf.write(text)

tests/test_code_content_text.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_code_text_c_256_bits():
6666

6767

6868
def test_normalize_text():
69-
txt = " Iñtërnâtiôn\nàlizætiøn☃💩 – is a tric\t ky \u00A0 thing!\r"
69+
txt = " Iñtërnâtiôn\nàlizætiøn☃💩 – is a tric\t ky \u00a0 thing!\r"
7070

7171
normalized = iscc_core.code_content_text.text_collapse(txt)
7272
assert normalized == "internationalizætiøn☃💩isatrickything"

tests/test_code_meta.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ def test_clean_text_markdowsn():
149149
More Text
150150
"""
151151

152-
assert ic.text_clean(text) == (
153-
"# Document\n"
152+
assert (
153+
ic.text_clean(text)
154+
== "# Document\n"
154155
"\n"
155156
"*Subtitle*\n"
156157
"\n"

tests/test_utils.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,13 @@ def test_hamming_distance_raises():
190190

191191

192192
def test_multi_hash_blake3():
193-
assert ic.multi_hash_blake3(b"") == (
194-
"1e20af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262"
193+
assert (
194+
ic.multi_hash_blake3(b"")
195+
== "1e20af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262"
195196
)
196-
assert ic.multi_hash_blake3(b"hello world") == (
197-
"1e20d74981efa70a0c880b8d8c1985d075dbcbf679b99a5f9914e5aaf96b831a9e24"
197+
assert (
198+
ic.multi_hash_blake3(b"hello world")
199+
== "1e20d74981efa70a0c880b8d8c1985d075dbcbf679b99a5f9914e5aaf96b831a9e24"
198200
)
199201

200202

tools/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Inspect full iscc_core api"""
2+
23
import inspect
34
from pprint import pprint
45
import iscc_core

tools/lf.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Convert line endings to LF"""
2+
23
import pathlib
34

45
HERE = pathlib.Path(__file__).parent.parent.absolute()

0 commit comments

Comments
 (0)