Skip to content

feat(sessions): renew, errors policy, and shared transport - #331

Open
shinybrar wants to merge 1 commit into
mainfrom
feat/client-improvements
Open

shinybrar wants to merge 1 commit into
mainfrom
feat/client-improvements

Conversation

@shinybrar

@shinybrar shinybrar commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add Session.renew / AsyncSession.renew and canfar renew to reset interactive Session lifetimes (parity with Science Portal / Skaha action=renew).
  • Add client errors / CANFAR_ERRORS and per-call errors= on lifecycle methods, raising SessionRequestError with partial results after every request runs.
  • Add caller-owned HTTPClient(transport=...) for shared connection pools (Bearer tokens only; clients never close the transport).

Closes #329

Test plan

  • uv run ruff check . --no-cache and uv run ty check canfar
  • uv run pytest tests -m "not slow" --no-cov -q
  • uv run pytest tests/test_skills.py --no-cov -q -n0
  • uv run --group docs mkdocs build
  • Manual: canfar renew SESSION_ID renews without a prompt and prints success/failure summaries
  • Manual: Session(errors="raise").destroy([...]) raises SessionRequestError with partial results
  • Manual: inject httpx2.HTTPTransport / AsyncHTTPTransport and confirm close does not shut down the pool

Enable Session renewal via Python and CLI, optional raise-on-failure
batch errors, and caller-owned httpx2 transport injection for #329.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.08333% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.19%. Comparing base (8aafe2e) to head (f9a225f).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
canfar/helpers/session.py 93.22% 4 Missing ⚠️
canfar/cli/renew.py 95.23% 0 Missing and 1 partial ⚠️
canfar/exceptions/session.py 92.30% 0 Missing and 1 partial ⚠️
canfar/sessions.py 98.97% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #331      +/-   ##
==========================================
+ Coverage   90.92%   91.19%   +0.27%     
==========================================
  Files          61       64       +3     
  Lines        4286     4454     +168     
  Branches      508      529      +21     
==========================================
+ Hits         3897     4062     +165     
  Misses        258      258              
- Partials      131      134       +3     
Flag Coverage Δ
3.10 91.19% <97.08%> (+0.27%) ⬆️
3.11 91.19% <97.08%> (+0.27%) ⬆️
3.12 91.19% <97.08%> (+0.27%) ⬆️
3.13 91.19% <97.08%> (+0.27%) ⬆️
3.14 91.19% <97.08%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add transport injection, error policies, and session renewal to clients

2 participants