fix: small correctness/security cleanups in apps-python / python-sdk examples#535
fix: small correctness/security cleanups in apps-python / python-sdk examples#535jamesbroadhead wants to merge 4 commits into
Conversation
Subset of fixes from the experimental-branch batch that apply to files present on main. (mas_manager.py and compute.py don't exist under databricks-skills/ on main; those fixes ship only on the experimental companion PR.) databricks-app-python/examples/llm_config.py: - OAuth error no longer interpolates the full token-endpoint payload (which can contain `id_token` / refresh material). Logs the present key names instead. - DATABRICKS_MODEL validation error drops the `response.text[:300]` echo so server bodies don't end up in operator-visible error text. databricks-app-python/examples/fm-minimal-chat.py: - Docstring + `app.yaml` examples reference the actual filename (`fm-minimal-chat.py`), not `2-minimal-chat-app.py`. databricks-app-python/examples/fm-parallel-calls.py: - Guard `Speedup` division on `total_time > 0` to avoid ZeroDivisionError on fast paths. - Convert the trailing standalone triple-quoted string (dead code) to real `#` comments. databricks-python-sdk/examples/5-serving-and-vector-search.py: - Replace the `[0.1, 0.2, 0.3, ...]` literal-Ellipsis vector with a named placeholder + comment explaining it's a stand-in. This pull request was AI-assisted by Isaac. Co-authored-by: Isaac
|
Hi @calreynolds — could you take a look at this when you have a moment? Subset of fixes for — this comment was written by Claude |
Mirrors the example-file polish from the experimental-branch PR. fm-parallel-calls.py - When total_time is below resolution, print "Speedup: N/A (total_time below resolution)" instead of silently omitting the line, so the user sees the metric was skipped rather than wondering where it went. 5-serving-and-vector-search.py - Replace the dim-3 [0.1, 0.2, 0.3] placeholder with [0.0] * 768 and a comment listing common embedding dimensions (768 / 1024 / 1536). The earlier value was small enough to mislead copy-pasters into thinking any short list works. Co-authored-by: Isaac
…ain) Round-3 review surfaced that nothing under databricks-skills/.tests/ was being run by CI on either branch. This wires up a unit-tests job for forward compatibility: when the .tests/ tree lands on main (currently on experimental only — companion PR databricks-solutions#534), CI will start running it automatically without a separate plumbing PR. The job guards on the directory's existence so it no-ops cleanly on branches that don't have .tests/ yet (i.e. main today). Once the tree arrives, the guard becomes a no-op and pytest runs. uvx + pytest + databricks-sdk + requests, deselecting @pytest.mark.integration (those need a real Databricks workspace). Co-authored-by: Isaac
|
Hi @QuentinAmbard — Claude here, working with James. Could you review this when you have a moment? Small set of correctness/security fixes to |
QuentinAmbard
left a comment
There was a problem hiding this comment.
files changed look good, but I think we need to work on the files like fm-parallel-calls.py, it's a lot of tokens for task that I think are already in foundation model global knowledge with duplicate that we could reduce/densify a lot, probably worth another PR
Summary
Subset of fixes surfaced by a parallel GPT 5.4 + Gemini 3.1 Pro code review, scoped to files that exist on
main. (The companion experimental-branch PR contains a larger superset;mas_manager.pyandcompute.pylive only underdatabricks-skills/onexperimental.)Commit history
databricks-skills/databricks-app-python/examples/llm_config.py(security)payload(which can containid_token/ refresh material). Logs the present key names instead.DATABRICKS_MODELvalidation error drops theresponse.text[:300]echo so server bodies don't end up in operator-visible error text.databricks-skills/databricks-app-python/examples/fm-minimal-chat.pyapp.yamlexamples reference the actual filename (fm-minimal-chat.py), not2-minimal-chat-app.py.databricks-skills/databricks-app-python/examples/fm-parallel-calls.pySpeedupdivision ontotal_time > 0; prints "Speedup: N/A (total_time below resolution)" when the metric can't be computed.#comments.databricks-skills/databricks-python-sdk/examples/5-serving-and-vector-search.pyEllipsis[0.1, 0.2, 0.3, ...]with[0.0] * 768and a comment naming common embedding dimensions (768 / 1024 / 1536); the previous value was small enough to mislead copy-pasters.Companion PR
Equivalent (larger) PR for
experimental— adds fixes tomas_manager.pyandcompute.pywhich exist there: #534Test plan
python3 -m py_compileon all modified filesThis pull request and its description were written by Isaac.