Skip to content

Commit

Permalink
Remove use of deprecated __ident_func__ from Werkzeug (#1559)
Browse files Browse the repository at this point in the history
* Remove use of deprecated __ident_func__ from Werkzeug

* Fix lint

* Fix mypy

* Try to fix docs test

* Go mod tidy is needed everywhere now randomly

Co-authored-by: Sam Scott <[email protected]>
  • Loading branch information
gkaemmer and samscott89 authored Apr 29, 2022
1 parent 9cc062b commit eb74b45
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions languages/python/sqlalchemy-oso/sqlalchemy_oso/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
"""

try:
from flask import _app_ctx_stack # type: ignore
from flask_sqlalchemy import SQLAlchemy, SignallingSession
except ImportError:
import warnings

warnings.warn(
"Missing depenedencies for Flask. Install sqlalchemy-oso with the flask extra."
"Missing dependencies for Flask. Install sqlalchemy-oso with the flask extra."
)
raise

try:
from greenlet import getcurrent as _get_ident # type: ignore
except ImportError:
from threading import get_ident as _get_ident # type: ignore

from sqlalchemy_oso.session import authorized_sessionmaker, scoped_session


Expand Down Expand Up @@ -47,7 +51,7 @@ def create_scoped_session(self, options=None):
if options is None:
options = {}

scopefunc = options.pop("scopefunc", _app_ctx_stack.__ident_func__)
scopefunc = options.pop("scopefunc", _get_ident)
return scoped_session(
get_oso=self._get_oso,
get_user=self._get_user,
Expand Down

1 comment on commit eb74b45

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: eb74b45 Previous: 9cc062b Ratio
rust_get_attribute 56141 ns/iter (± 6133) 61608 ns/iter (± 5690) 0.91
n_plus_one/100 2540209 ns/iter (± 201816) 2826721 ns/iter (± 263420) 0.90
n_plus_one/500 13231565 ns/iter (± 870373) 13799469 ns/iter (± 1044041) 0.96
n_plus_one/1000 27667984 ns/iter (± 1655230) 27126166 ns/iter (± 1630714) 1.02
unify_once 1247 ns/iter (± 133) 1247 ns/iter (± 117) 1
unify_twice 3218 ns/iter (± 612) 3403 ns/iter (± 1311) 0.95
many_rules 80652 ns/iter (± 9735) 86558 ns/iter (± 7039) 0.93
fib/5 630082 ns/iter (± 48400) 679961 ns/iter (± 67724) 0.93
prime/3 21809 ns/iter (± 3149) 23596 ns/iter (± 2718) 0.92
prime/23 21718 ns/iter (± 2185) 24474 ns/iter (± 2343) 0.89
prime/43 21259 ns/iter (± 2672) 23586 ns/iter (± 3131) 0.90
prime/83 22778 ns/iter (± 2848) 23456 ns/iter (± 1635) 0.97
prime/255 20842 ns/iter (± 2408) 22025 ns/iter (± 1974) 0.95
indexed/100 7386 ns/iter (± 1683) 8269 ns/iter (± 2108) 0.89
indexed/500 9584 ns/iter (± 2955) 10946 ns/iter (± 3133) 0.88
indexed/1000 11453 ns/iter (± 1779) 13513 ns/iter (± 2072) 0.85
indexed/10000 27900 ns/iter (± 12631) 32025 ns/iter (± 7799) 0.87
not 7665 ns/iter (± 1241) 7691 ns/iter (± 683) 1.00
double_not 14217 ns/iter (± 1552) 15853 ns/iter (± 1162) 0.90
De_Morgan_not 9115 ns/iter (± 819) 10160 ns/iter (± 1395) 0.90
load_policy 1178263 ns/iter (± 79243) 1174156 ns/iter (± 69889) 1.00
partial_and/1 39560 ns/iter (± 10373) 41992 ns/iter (± 3804) 0.94
partial_and/5 143047 ns/iter (± 9304) 147264 ns/iter (± 21536) 0.97
partial_and/10 275382 ns/iter (± 27704) 275439 ns/iter (± 21027) 1.00
partial_and/20 528699 ns/iter (± 40472) 554392 ns/iter (± 28499) 0.95
partial_and/40 1119977 ns/iter (± 85192) 1202556 ns/iter (± 71362) 0.93
partial_and/80 2758580 ns/iter (± 182228) 2771291 ns/iter (± 171269) 1.00
partial_and/100 3429950 ns/iter (± 210561) 3687553 ns/iter (± 197262) 0.93
partial_rule_depth/1 118135 ns/iter (± 10517) 128273 ns/iter (± 10036) 0.92
partial_rule_depth/5 420451 ns/iter (± 27245) 421665 ns/iter (± 32029) 1.00
partial_rule_depth/10 853491 ns/iter (± 79672) 918721 ns/iter (± 96231) 0.93
partial_rule_depth/20 2456727 ns/iter (± 185220) 2789835 ns/iter (± 184261) 0.88
partial_rule_depth/40 9690792 ns/iter (± 741383) 10517720 ns/iter (± 612897) 0.92
partial_rule_depth/80 64874303 ns/iter (± 7202978) 68877275 ns/iter (± 4515650) 0.94
partial_rule_depth/100 114232090 ns/iter (± 6398904) 125939953 ns/iter (± 4981357) 0.91

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.