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

Adapt Tools CLI to uv #1455

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Adapt Tools CLI to uv #1455

merged 2 commits into from
Oct 16, 2024

Conversation

vinibrsl
Copy link
Member

This pull request adapts commands from the Tool CLI from Poetry to uv.

Extra comments inline 👇

@@ -25,7 +25,9 @@ def __init__(self, api_key: str) -> None:

def _make_request(self, method: str, endpoint: str, **kwargs) -> requests.Response:
url = urljoin(self.base_url, endpoint)
return requests.request(method, url, headers=self.headers, **kwargs)
session = requests.Session()
session.trust_env = False
Copy link
Member Author

@vinibrsl vinibrsl Oct 16, 2024

Choose a reason for hiding this comment

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

trust_env = False tells requests to bypass the system's authentication or proxy settings, relying only on the authentication defined in the request itself.

The reason for this change is that when a .netrc file is present, requests automatically replaces the Authorization header with the credentials from .netrc, overwriting Auth0 credentials.

While trust_env = False fixes the issue, alongside I'm proposing moving our custom PyPI index endpoints from app.crewai.com to tools.crewai.com. This ensures .netrc is only applied to that specific subdomain system-wide.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Your suggestion makes total sense.

# Create .netrc or _netrc file
netrc_filename = "_netrc" if platform.system() == "Windows" else ".netrc"
netrc_path = Path.home() / netrc_filename
def _set_netrc_credentials(self, credentials, netrc_path=None):
Copy link
Member Author

Choose a reason for hiding this comment

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

I refactored it to use Python's builtin netrc package.

password {credentials['password']}
"""
netrc_instance = netrc(file=netrc_path)
netrc_instance.hosts["app.crewai.com"] = (credentials["username"], "", credentials["password"])
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the line we need to change after we migrate to tools.crewai.com.

@vinibrsl vinibrsl merged commit a6b7295 into main Oct 16, 2024
4 checks passed
@vinibrsl vinibrsl deleted the tools-uv branch October 16, 2024 13:55
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.

2 participants