Skip to content

Conversation

@saimanikant
Copy link
Collaborator

@saimanikant saimanikant commented Aug 11, 2025

Description

Addressing: #106

How to test:
In data-transfer config add:

"auth": {
"auto_config_worker": true
}

Restart docker service, set Access Token Lifespan to something like 30 second.
Can we do more with testing?
Do we want a callback for AsyncClient as well?

Checklist

  • I have tested these changes locally.
  • I have added unit tests (if appropriate).
  • I have added necessary documentation or updated existing documentation.
  • I have linked the issue(s) addressed by this PR if any.

@github-actions github-actions bot added the maintenance Package and maintenance related label Aug 11, 2025
@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 94.44444% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.10%. Comparing base (ed46a18) to head (d57a4e3).

Files with missing lines Patch % Lines
src/ansys/hps/data_transfer/client/client.py 94.44% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
- Coverage   84.22%   84.10%   -0.13%     
==========================================
  Files          17       17              
  Lines        1509     1560      +51     
==========================================
+ Hits         1271     1312      +41     
- Misses        238      248      +10     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Aug 11, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Aug 14, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Aug 14, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Aug 14, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Aug 14, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Aug 15, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Aug 15, 2025
>>> from ansys.hps.data_transfer.client import Client
>>> token = authenticate(username=username, password=password, verify=False, url=auth_url)
>>> token = token.get("access_token", None)
>>> def refresh_token():
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe call it refresh_token_cb or similar to disambiguate from the refresh_token itself

>>> token = token.get("access_token", None)
>>> def refresh_token():
# Function to refresh the token
token = authenticate(username=username, self.password, verify=False, url=auth_url)
Copy link
Collaborator

Choose a reason for hiding this comment

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

self.password --> just password?

def __init__(self, *args, refresh_token_callback: Callable[[], Awaitable[str]] = None, **kwargs):
"""Initializes the AsyncClient class object."""
super().__init__(*args, **kwargs)
self.refresh_token_callback = refresh_token_callback # Override the callback
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you need to override it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

overriding refresh_token_callback in the AsyncClient class for it to be asynchronous (Callable[[], Awaitable[str]]) because the parent class defines it (Callable[[], str])

Copy link
Collaborator

Choose a reason for hiding this comment

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

The changes here as well as the content of the async version (with the loop on get storage) seem to me more of a script to test tokens than an examples. It's fine to keep this code around as a script, but I think it should not a user-facing example.

@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Sep 22, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Sep 22, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Sep 22, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Sep 22, 2025
@github-actions github-actions bot added maintenance Package and maintenance related and removed maintenance Package and maintenance related labels Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Package and maintenance related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React to 401 http errors, execute a callback and retry the request

4 participants