Skip to content
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

feat: only one api key #798

Merged
merged 2 commits into from
Jan 21, 2025
Merged

feat: only one api key #798

merged 2 commits into from
Jan 21, 2025

Conversation

SAKURA-CAT
Copy link
Contributor

Description

This pull request includes several changes to the swanlab/package.py file and the associated unit tests to improve the handling of .netrc files and ensure that only one host entry is maintained. The most important changes include the addition of a new function to get the .netrc file path, updates to existing functions to use this new function, and enhancements to the unit tests to verify the new behavior.

Enhancements to .netrc file handling:

  • swanlab/package.py: Added a new function get_nrc_path() to obtain the .netrc file path.
  • swanlab/package.py: Updated the get_key() and save_key() functions to use the new get_nrc_path() function for obtaining the .netrc file path. [1] [2]
  • swanlab/package.py: Modified the save_key() function to avoid writing duplicate host entries and ensure only one host entry is maintained.

Improvements to unit tests:

  • test/unit/test_package.py: Enhanced the test_ok test to verify that only one host entry is maintained after saving a new host.
  • test/unit/test_package.py: Added a new test test_duplicate to check the behavior of saving duplicate entries, ensuring that the .netrc file is not modified unnecessarily.

closes #797

@SAKURA-CAT SAKURA-CAT requested a review from Zeyi-Lin January 21, 2025 06:35
@SAKURA-CAT SAKURA-CAT self-assigned this Jan 21, 2025
@SAKURA-CAT SAKURA-CAT added the 💪 enhancement New feature or request label Jan 21, 2025
@SAKURA-CAT SAKURA-CAT merged commit ec4312c into main Jan 21, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat/only-api-key branch January 21, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REQUEST] 同时只应该保存一个api key
2 participants