-
Notifications
You must be signed in to change notification settings - Fork 117
SG-33297 WIP #1032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
SG-33297 WIP #1032
Conversation
self._user_settings = UserSettings() | ||
self._system_settings = SystemSettings() | ||
self._fixed_host = fixed_host | ||
self._host = False # current value might be None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
5d87509
to
0d61453
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances performance and usability by introducing content caching, streamlining authentication defaults handling, and improving logging and UI flows.
- Added a YAML content cache with automatic invalidation to reduce redundant file reads.
- Cached default host and login values in the defaults manager for faster lookups.
- Extended the logger with a reset method, timestamped log output, and refactored site-change and login dialog behaviors.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
python/tank/log.py | Added reset_logger , adjusted formatter to include timestamps. |
python/tank/authentication/site_info.py | Left placeholder TODOs and commented-out debug/sleep code. |
python/tank/authentication/shotgun_authenticator.py | Inserted unprefixed TODO lines in get_default_user . |
python/tank/authentication/session_cache.py | Introduced _YML_CONMTENT_CACHE with timeout-based invalidation. |
python/tank/authentication/login_dialog.py | Refactored _on_site_changed , initialized spinner, early return in _toggle_web . |
python/tank/authentication/defaults_manager.py | Cached _host and _login values, updated getters/setters. |
Comments suppressed due to low confidence (1)
python/tank/authentication/shotgun_authenticator.py:235
- Uncommented TODO line causes syntax error; prefix with
#
or move into a proper comment or docstring.
TODO this method's name and description is not accurate. This method tries to return the current user with credentials. ...
|
||
# example: [DEBUG tank.log] message message | ||
formatter = logging.Formatter("[%(levelname)s %(name)s] %(message)s") | ||
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s") |
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new log formatter omits the logger name, which can make identifying the source module harder; consider including %(name)s
in the format string.
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s") | |
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s") |
Copilot uses AI. Check for mistakes.
# logger.info("Sleep for 10s") | ||
# time.sleep(30) | ||
# logger.info("done sleeping") | ||
|
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Remove or clarify commented-out debug code and stray TODO comments to improve readability and maintainability.
# logger.info("Sleep for 10s") | |
# time.sleep(30) | |
# logger.info("done sleeping") |
Copilot uses AI. Check for mistakes.
_YML_CONMTENT_CACHE = {} | ||
_YML_CONMTENT_CACHE_TIMEOUT = 300 # 5 minutes | ||
|
||
def _try_load_yaml_file(file_path): | ||
global _YML_CONMTENT_CACHE | ||
global _YML_CONMTENT_CACHE_TIMEOUT | ||
|
||
cache = _YML_CONMTENT_CACHE.get(file_path, None) | ||
if cache and (time.time() - _YML_CONMTENT_CACHE_TIMEOUT > cache.get("timeout", 0)): | ||
try: | ||
del(_YML_CONMTENT_CACHE[file_path]) |
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in constant name _YML_CONMTENT_CACHE
; 'CONMTENT' should be 'CONTENT' for clarity.
_YML_CONMTENT_CACHE = {} | |
_YML_CONMTENT_CACHE_TIMEOUT = 300 # 5 minutes | |
def _try_load_yaml_file(file_path): | |
global _YML_CONMTENT_CACHE | |
global _YML_CONMTENT_CACHE_TIMEOUT | |
cache = _YML_CONMTENT_CACHE.get(file_path, None) | |
if cache and (time.time() - _YML_CONMTENT_CACHE_TIMEOUT > cache.get("timeout", 0)): | |
try: | |
del(_YML_CONMTENT_CACHE[file_path]) | |
_YML_CONTENT_CACHE = {} | |
_YML_CONTENT_CACHE_TIMEOUT = 300 # 5 minutes | |
def _try_load_yaml_file(file_path): | |
global _YML_CONTENT_CACHE | |
global _YML_CONTENT_CACHE_TIMEOUT | |
cache = _YML_CONTENT_CACHE.get(file_path, None) | |
if cache and (time.time() - _YML_CONTENT_CACHE_TIMEOUT > cache.get("timeout", 0)): | |
try: | |
del(_YML_CONTENT_CACHE[file_path]) |
Copilot uses AI. Check for mistakes.
) | ||
|
||
def _toggle_web(self, method_selected=None): | ||
return |
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Early return at the start of _toggle_web
prevents any logic from running, making the method effectively dead code; remove or adjust this return.
return |
Copilot uses AI. Check for mistakes.
otherwise, create this change: -from . import QtCore +from tank.platform.qt import QtCore
uic script said: > Warning: The name 'verticalLayout_2' (QVBoxLayout) is already in > use, defaulting to 'verticalLayout_21'.
8c9e895
to
b6d084d
Compare
b6d084d
to
e41f258
Compare
self.site_info = site_info | ||
|
||
|
||
# what if url is empty or site_info is empty??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many blank lines (2)
|
||
self._on_site_changed() # trigger the first site info request | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
return INFOS_CACHE[url][1] | ||
|
||
def _retrieve_site_info(url, http_proxy=None): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
over-indented
|
||
return INFOS_CACHE[url][1] | ||
|
||
def _retrieve_site_info(url, http_proxy=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
INFOS_CACHE = {} | ||
|
||
|
||
def get(url: str, http_proxy: str|None=None, cache_only=False) -> SiteInfo|None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace around bitwise or shift operator
missing whitespace around parameter equals
return self._infos.get("authentication_app_session_launcher_enabled", False) | ||
|
||
# Cache the servers infos for 30 seconds. | ||
INFOS_CACHE_TIMEOUT = 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines after class or function definition, found 1
self._infos = {} | ||
|
||
def reload(self, url, http_proxy=None): | ||
class SiteInfo: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
expected 2 blank lines, found 1
# guess here. | ||
prev_selected_method = session_cache.get_preferred_method(site) | ||
else: | ||
prev_selected_method = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local variable 'prev_selected_method' is assigned to but never used
) | ||
|
||
def _toggle_web(self, method_selected=None): | ||
def _update_login_page_ui(self, auth_method: int|None=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace around bitwise or shift operator
missing whitespace around parameter equals
This pull request introduces several updates to the authentication and logging modules, focusing on improving caching mechanisms, refining user interface behaviors, and enhancing logging functionality. The changes streamline the handling of user authentication data, optimize caching for YAML files, and improve logging output formatting. Additionally, there are adjustments to UI elements and method logic in the login dialog to provide a smoother user experience.
Authentication Updates
python/tank/authentication/defaults_manager.py
: Implemented caching forhost
andlogin
values to avoid redundant computations and added logic to resetlogin
whenhost
is updated. [1] [2] [3] [4]python/tank/authentication/session_cache.py
: Introduced a caching mechanism for YAML file content with a timeout of 5 minutes to improve performance. Updated session data retrieval logic to remove unnecessaryNone
returns and clarified debug messages for missing authentication info. [1] [2] [3]UI Enhancements
python/tank/authentication/login_dialog.py
: Replaced_update_ui_according_to_site_support
with_on_site_changed
for better site change handling. Added a spinner to indicate site information retrieval and adjusted method logic to prevent redundant UI updates. [1] [2] [3] [4]Logging Improvements
python/tank/log.py
: Added areset_logger
method to allow resetting the logger instance and updated the log formatter to include timestamps for better traceability. [1] [2]Code Cleanup and Clarifications
python/tank/authentication/shotgun_authenticator.py
: Added TODO comments to clarify misleading method names and descriptions. [1] [2]python/tank/authentication/site_info.py
: Added TODO comments to suggest emitting signals for site info updates and consuming cache more effectively.This pull request introduces several changes across multiple files to improve caching mechanisms, streamline authentication flows, and enhance logging functionality. Key updates include the addition of caching for YAML file contents, modifications to host and login handling in the defaults manager, and adjustments to logging formats and methods.Caching Improvements:
python/tank/authentication/session_cache.py
: Introduced_YML_CONMTENT_CACHE
for caching YAML file contents with a timeout mechanism to reduce redundant file reads. Added logic to clear cache entries when outdated. [1] [2]Authentication Flow Enhancements:
python/tank/authentication/defaults_manager.py
: Improved handling of host and login values by introducing_host
and_login
attributes with defaultFalse
values, ensuring consistent initialization and caching. Updated methods such asget_host
andget_login
to use these attributes for better performance. [1] [2] [3]python/tank/authentication/login_dialog.py
: Refactored site change handling in_on_site_changed
and_toggle_web
methods to prevent unnecessary updates and improve site selection logic. Deprecated unused methods and added more descriptive logging. [1] [2]Logging Enhancements:
python/tank/log.py
: Added areset_logger
method to allow resetting the singleton logger instance. Updated the log formatter ininitialize_custom_handler
to include timestamps for better traceability. [1] [2]Miscellaneous Fixes:
python/tank/authentication/session_cache.py
: Updated method descriptions and logging statements for clarity, including changes toget_session_data
andget_current_host
. [1] [2]python/tank/authentication/shotgun_authenticator.py
: Added TODO comments to highlight misleading method names and descriptions for future refactoring. [1] [2]