Skip to content

Commit

Permalink
Merge pull request #356 from square/naman/exclude-pyrsistent-version
Browse files Browse the repository at this point in the history
  • Loading branch information
namanjain committed Nov 14, 2022
2 parents 357da8e + 8ae96ad commit c92e4d0
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 50 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/bionic-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ jobs:
# version.)
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8]
include:
- python-version: 3.6
shard-id: 0
- python-version: 3.7
shard-id: 1
- python-version: 3.8
Expand All @@ -44,7 +42,7 @@ jobs:
# build failures.
pip freeze
- name: Set up gcloud
uses: google-github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@main
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
Expand Down
2 changes: 1 addition & 1 deletion bionic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
from . import protocol # noqa: F401
from . import util # noqa: F401

__version__ = u"0.11.0"
__version__ = "0.11.0"
7 changes: 3 additions & 4 deletions bionic/code_hasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@


PREFIX_SEPARATOR = b"$"
# This is gross but types.MethodWrapperType was introduced in Python 3.7
# and does not exist in 3.6 which Bionic supports.
METHOD_WRAPPER_TYPE = type("".__str__)


class CodeHasher:
Expand Down Expand Up @@ -290,7 +287,9 @@ def _update_hash(self, hash_accumulator, obj, code_context):
obj_bytes=self._check_and_hash(builtin_name, code_context),
)

elif inspect.ismethoddescriptor(obj) or isinstance(obj, METHOD_WRAPPER_TYPE):
elif inspect.ismethoddescriptor(obj) or isinstance(
obj, types.MethodWrapperType
):
if inspect.ismethoddescriptor(obj):
type_prefix = TypePrefix.METHOD_DESCRIPTOR
else:
Expand Down
1 change: 1 addition & 0 deletions bionic/deps/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def combine(*dep_lists):
"flake8",
"flake8-print",
"flake8-fixme",
"importlib-metadata<5", # flake8 is incompatible with importlib 5.0.0
"sphinx!=3.2.0",
"sphinx_rtd_theme",
"sphinx-autobuild",
Expand Down
2 changes: 1 addition & 1 deletion bionic/flake8/check_dnode_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@ def run(self):
code = Path(filename).read_text()
tree = ast.parse(code)
for message in Checker(tree).run():
print(message) # noqa: T001
print(message) # noqa: T201
16 changes: 8 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

# -- Project information -----------------------------------------------------

project = u"bionic"
copyright = u"2019, Square"
author = u"Janek Klawe"
project = "bionic"
copyright = "2019, Square"
author = "Janek Klawe"

# The short X.Y version
version = u"0.11.0"
version = "0.11.0"
# The full version, including alpha/beta/rc tags
release = version

Expand Down Expand Up @@ -67,7 +67,7 @@
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
u"_build",
"_build",
"Thumbs.db",
".DS_Store",
"**.ipynb_checkpoints",
Expand Down Expand Up @@ -135,15 +135,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "bionic.tex", u"bionic Documentation", u"Janek Klawe", "manual"),
(master_doc, "bionic.tex", "bionic Documentation", "Janek Klawe", "manual"),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "bionic", u"bionic Documentation", [author], 1)]
man_pages = [(master_doc, "bionic", "bionic Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------------
Expand All @@ -155,7 +155,7 @@
(
master_doc,
"bionic",
u"bionic Documentation",
"bionic Documentation",
author,
"bionic",
"One line description of project.",
Expand Down
2 changes: 1 addition & 1 deletion docs/get-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ performance for some workloads. LibYAML is also available via Homebrew:
brew install libyaml
Bionic supports Python 3.6 and above.
Bionic supports Python 3.7 and above.

.. _extra-packages:

Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ ignore =
T102 # "fixme found (XXX)"
per-file-ignores =
# Allow print statements in example code.
example/*:T001
build/lib/example/*:T201
example/*:T201

# NOTE On my MacBook this plugin adds about 1 extra second to Flake8's runtime, making
# it about 5s total. That's not trivial, so it might not be worth it to have this
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"numpy",
"pandas",
"pyarrow",
"pyrsistent",
"pyrsistent!=0.19.1",
"decorator<5",
]

setup(
Expand All @@ -42,7 +43,7 @@
include_package_data=True,
install_requires=requirements,
extras_require=extras_require,
python_requires=">=3.6",
python_requires=">=3.7",
zip_safe=False,
keywords="bionic",
classifiers=[
Expand All @@ -51,6 +52,6 @@
"Natural Language :: English",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
)
2 changes: 1 addition & 1 deletion tests/test_code_hasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def dec_with_one(x):
return x - one()

def quadratic_eq(a, b, c):
d = b ** 2 - 4 * a * c
d = b**2 - 4 * a * c
s1 = (b - cmath.sqrt(d)) / (2 * a)
s2 = (-b - cmath.sqrt(d)) / (2 * a)
return (s1, s2)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_flow/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def real_gcs_session_tmp_url_prefix(real_gcs_url_stem) -> Optional[str]:

gcs_fs = get_gcs_fs_without_warnings()

random_hex_str = "%016x" % random.randint(0, 2 ** 64)
random_hex_str = "%016x" % random.randint(0, 2**64)
path_str = f"{getpass.getuser()}/BNTESTDATA/{random_hex_str}"

gs_url = real_gcs_url_stem + "/" + path_str + "/"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_flow/test_cache_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def xy(x, y):

@builder
def xy_squared(xy):
return xy ** 2
return xy**2

return builder.build()

Expand Down Expand Up @@ -134,7 +134,7 @@ def test_get_entries(preset_flow):
@builder # noqa: F811
@bn.version(1)
def xy(x, y): # noqa: F811
return x ** y
return x**y

tester.flow = builder.build()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_flow/test_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def xs(n):

@builder
def ys(xs):
return [x ** 2 for x in xs]
return [x**2 for x in xs]

return builder

Expand Down
4 changes: 2 additions & 2 deletions tests/test_flow/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def merge_tester(builder):

@fb
def x(root_x):
return root_x ** 2
return root_x**2

tester.add("DerivedSingle", fb.build())

Expand Down Expand Up @@ -167,7 +167,7 @@ def x(x_y): # noqa: F811
@fb # noqa: F811
@bn.persist(False)
def x(root_x): # noqa: F811
return root_x ** 2
return root_x**2

tester.add("DS", fb.build())

Expand Down
14 changes: 7 additions & 7 deletions tests/test_flow/test_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def f(x, y): # noqa: F811
@bn.version_no_warnings(major=1, minor=1)
def f(x, y): # noqa: F811
call_counter.mark()
return x ** y
return x**y

assert builder.build().get("f") == 6
assert call_counter.times_called() == 0
Expand All @@ -291,7 +291,7 @@ def f(x, y): # noqa: F811
@bn.version_no_warnings(major=2)
def f(x, y): # noqa: F811
call_counter.mark()
return x ** y
return x**y

assert builder.build().get("f") == 8
assert call_counter.times_called() == 1
Expand Down Expand Up @@ -435,7 +435,7 @@ def f(x, y): # noqa: F811
@bn.version_no_warnings(major=1, minor=1)
def f(x, y): # noqa: F811
call_counter.mark()
return x ** y
return x**y

with raises_versioning_error_for_entity("f"):
builder.build().get("f")
Expand All @@ -446,7 +446,7 @@ def f(x, y): # noqa: F811
@bn.version_no_warnings(major=2)
def f(x, y): # noqa: F811
call_counter.mark()
return x ** y
return x**y

assert builder.build().get("f") == 8
assert call_counter.times_called() == 1
Expand Down Expand Up @@ -504,7 +504,7 @@ def f(x, y): # noqa: F811
assert call_counter.times_called() == 0

def op(x, y): # noqa: F811
return x ** y
return x**y

with raises_versioning_error_for_entity("f"):
builder.build().get("f")
Expand Down Expand Up @@ -733,7 +733,7 @@ def f(x, y): # noqa: F811
@bn.version_no_warnings(major=1, minor=1)
def f(x, y): # noqa: F811
call_counter.mark()
return x ** y
return x**y

assert builder.build().get("f") == 8
assert call_counter.times_called() == 1
Expand All @@ -744,7 +744,7 @@ def f(x, y): # noqa: F811
@bn.version_no_warnings(major=2)
def f(x, y): # noqa: F811
call_counter.mark()
return x ** y
return x**y

assert builder.build().get("f") == 8
assert call_counter.times_called() == 1
Expand Down
11 changes: 1 addition & 10 deletions tests/test_flow/test_persistence_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import shutil
import sys

from .generate_test_compatibility_cache import Harness, CACHE_TEST_DIR

Expand All @@ -26,15 +25,7 @@ def older_serialized_cache_harness(make_counter, tmp_path):
# To renegerate cache, run the following command from bionic/ dir
# `python -m tests.test_flow.generate_test_compatibility_cache`
def test_caching_compatibility(older_serialized_cache_harness):
# The auto-versioned flow generates different bytecode hashes on Python 3.6
# compared to 3.7 and 3.8 This is because Python 3.7 added new
# bytecode instructions like LOAD_METHOD and uses them widely.
# We skip the auto-versioned flow for Python 3.6 and only test it on
# Python 3.7+.
if sys.version_info < (3, 7):
flows = [older_serialized_cache_harness.manual_flow]
else:
flows = older_serialized_cache_harness.flows
flows = older_serialized_cache_harness.flows

for flow in flows:
assert (
Expand Down
6 changes: 3 additions & 3 deletions tests/test_flow/test_persistence_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def xy(x, y): # noqa: F811
@bn.version_no_warnings(major=1)
def xy(x, y): # noqa: F811
call_counter.mark()
return x ** y
return x**y

flow = builder.build()

Expand All @@ -200,7 +200,7 @@ def test_indirect_versioning(preset_gcs_builder, make_counter):
@bn.version_no_warnings(major=1)
def xy(x, y):
call_counter.mark()
return x ** y
return x**y

flow = builder.build()
assert flow.get("xy") == 8
Expand Down Expand Up @@ -240,7 +240,7 @@ def xy(x, y): # noqa: F811
@bn.version_no_warnings(major=2)
def xy(x, y): # noqa: F811
call_counter.mark()
return y ** x
return y**x

flow = builder.build()

Expand Down

0 comments on commit c92e4d0

Please sign in to comment.