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

Add methods to provide extra user agent and upstream user agent to sdk config #163

Merged
merged 3 commits into from
Jun 14, 2023

Conversation

kartikgupta-db
Copy link
Contributor

Changes

  • Add with_user_agent_extra to allow users to specify extra user agents.
  • Add environment variable lookup for DATABRICKS_SDK_UPSTREAM and DATABRICKS_SDK_UPSTREAM_VERSION to allow products interacting with SDK through env vars to pass their product info.

Tests

  • unit tests
  • make test run locally
  • make fmt applied

@kartikgupta-db kartikgupta-db requested a review from nfx June 12, 2023 21:52
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04 🎉

Comparison is base (8660cff) 53.27% compared to head (6987f33) 53.31%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #163      +/-   ##
==========================================
+ Coverage   53.27%   53.31%   +0.04%     
==========================================
  Files          30       30              
  Lines       18178    18194      +16     
==========================================
+ Hits         9684     9700      +16     
  Misses       8494     8494              
Impacted Files Coverage Δ
databricks/sdk/core.py 67.86% <100.00%> (+0.72%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

databricks/sdk/core.py Outdated Show resolved Hide resolved

@property
def _upstream_user_agent(self) -> str:
product = os.environ.get('DATABRICKS_SDK_UPSTREAM', None)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also add the relevant Go SDK PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. This was a bigger priority because I would like to get dbconnect to start using this asap.
Working on go sdk today.

@kartikgupta-db kartikgupta-db requested a review from nfx June 14, 2023 09:15
@kartikgupta-db kartikgupta-db enabled auto-merge (squash) June 14, 2023 09:16
@kartikgupta-db kartikgupta-db merged commit a33b5ae into main Jun 14, 2023
nfx added a commit that referenced this pull request Jun 15, 2023
* Regenerate from OpenAPI spec ([#176](#176)).
* Added improved notebook-native authentication ([#152](#152)).
* Added methods to provide extra user agent and upstream user agent to SDK config ([#163](#163)).
* Added more missing `Optional` type hints ([#171](#171)).
* Add more missing optional fields ([#177](#177)).
* Correctly serialize external entities ([#178](#178)).
* Correctly serialize external enum values in paths ([#179](#179)).
* Mark non-required fields as `Optional` ([#170](#170)).
* Synchronize auth permutation tests with Go SDK ([#165](#165)).
@nfx nfx mentioned this pull request Jun 15, 2023
1 task
nfx added a commit that referenced this pull request Jun 15, 2023
* Regenerate from OpenAPI spec
([#176](#176)).
* Added improved notebook-native authentication
([#152](#152)).
* Added methods to provide extra user agent and upstream user agent to
SDK config
([#163](#163)).
* Added more missing `Optional` type hints
([#171](#171)).
* Added more missing optional fields
([#177](#177)).
* Correctly serialize external entities
([#178](#178)).
* Correctly serialize external enum values in paths
([#179](#179)).
* Mark non-required fields as `Optional`
([#170](#170)).
* Synchronize auth permutation tests with Go SDK
([#165](#165)).

## Tests

- [x] relevant integration tests applied

---------

Signed-off-by: Serge Smertin <259697+nfx@users.noreply.github.com>
github-merge-queue bot pushed a commit to databricks/databricks-sdk-go that referenced this pull request Mar 13, 2024
…854)

## Changes
This PR ports databricks/databricks-sdk-py#163
to the Go SDK. This enables partners who use the SDK through a tool
(like Terraform) to add custom information to the user agent without
having to make code changes to the tool.

Closes #850.

## Tests
Added unit test to verify that the user agent is only updated when both
DATABRICKS_SDK_UPSTREAM and DATABRICKS_SDK_UPSTREAM_VERSION are set.

Manually ran `examples/slog` to verify that the user agent is correctly
updated.
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.

3 participants