Title: Performance [P3]: Cache Azure managed SDK version lookup by berndverst · Pull Request #203 · microsoft/durabletask-python · GitHub
Open Graph Title: Performance [P3]: Cache Azure managed SDK version lookup by berndverst · Pull Request #203 · microsoft/durabletask-python
X Title: Performance [P3]: Cache Azure managed SDK version lookup by berndverst · Pull Request #203 · microsoft/durabletask-python
Description: Summary Both the sync (DTSDefaultClientInterceptorImpl) and async (DTSAsyncDefaultClientInterceptorImpl) interceptor constructors called importlib.metadata.version('durabletask-azuremanaged') directly. That call walks distribution metadata on disk, so the work was repeated on every interceptor construction — i.e. on every client and worker construction. This change resolves the version once in a module-level functools.lru_cached helper (_get_sdk_version()) and reuses it for every interceptor. Preserved exactly The "unknown" fallback when the version cannot be determined (the helper keeps the original broad except Exception, which still covers importlib.metadata.PackageNotFoundError). The user-agent string format, durabletask-python/{version}, verbatim. The metadata key names and their order: taskhub, x-user-agent, and workerid (sync worker case only). No public API signature changes, no renames, no removed symbols, no changed import paths. The only observable difference is the removed repeat filesystem work. NoteNo changelog entry was added. This is an internal performance change with no user-visible behavior difference, which the repo guidelines say should not be documented in the changelog. Verification Ran against a session-local virtualenv with both packages installed in editable mode. Effectiveness (the actual fix). A probe patched the module-level version symbol and counted calls across three interceptor constructions (sync client, sync worker, async): Variant version() calls Before (uncached) 3 After (cached) 1 Tests. New TestSdkVersionCaching::test_version_resolved_once_across_interceptor_constructions asserts the lookup happens exactly once across three constructions, and pins the full metadata list (keys and order) for all three cases. New TestSdkVersionCaching::test_unknown_fallback_when_version_cannot_be_determined asserts PackageNotFoundError still yields durabletask-python/unknown for both the sync and async interceptors. Both new tests clear the cache in setUp/tearDown so no patched value leaks into other tests. Existing test_worker_includes_workerid_header and test_user_agent_metadata_passed_in_request still pass unchanged. Suites. Provider unit tests (test_durabletask_grpc_interceptor.py, test_sandboxes_extension.py, test_azuremanaged_grpc_resiliency.py): 47 passed. Core unit tests (tests/durabletask, excluding *_e2e.py): 681 passed, 7 skipped. flake8 clean on both changed files. pyright (repo pyrightconfig.json, strict): 441 errors before and after, none in the changed file — unchanged from baseline. *_e2e.py suites and test_dts_activity_sequence.py need a live Durable Task Scheduler endpoint and were not run. Fixes #195
Open Graph Description: Summary Both the sync (DTSDefaultClientInterceptorImpl) and async (DTSAsyncDefaultClientInterceptorImpl) interceptor constructors called importlib.metadata.version('durabletask-azuremanaged'...
X Description: Summary Both the sync (DTSDefaultClientInterceptorImpl) and async (DTSAsyncDefaultClientInterceptorImpl) interceptor constructors called importlib.metadata.version('durabletask-azuremanaged...
Opengraph URL: https://github.com/microsoft/durabletask-python/pull/203
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d75244d2-095a-0052-8622-6be0d3599194 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D932:398661:21DAE3:2E30FE:6AFE4BD3 |
| html-safe-nonce | 84e42bb56ee7a3d21bab2c8e3057149c11bca78b424e238f4b23efb504b5716b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTMyOjM5ODY2MToyMURBRTM6MkUzMEZFOjZBRkU0QkQzIiwidmlzaXRvcl9pZCI6IjgxOTc5NjczMDU2MDczNjc2MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 678bce17de130e3349024daca884e6f4bfa0bff3774501299cda70381fc47cf7 |
| hovercard-subject-tag | pull_request:4139788210 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/microsoft/durabletask-python/pull/203/files |
| twitter:image | https://avatars.githubusercontent.com/u/4535280?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4535280?s=400&v=4 |
| og:image:alt | Summary Both the sync (DTSDefaultClientInterceptorImpl) and async (DTSAsyncDefaultClientInterceptorImpl) interceptor constructors called importlib.metadata.version('durabletask-azuremanaged'... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 894d3c8b932306ed8425e8dcbe0c1089667e487c5fe7b8a05d17e7b685207429 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 627664515 |
| octolytics-dimension-repository_nwo | microsoft/durabletask-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627664515 |
| octolytics-dimension-repository_network_root_nwo | microsoft/durabletask-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44570ad53e12be09be8000af683c29166c4007cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width