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

Added propagation of blueprint version into User-Agent header when it is used as library #114

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

nfx
Copy link
Collaborator

@nfx nfx commented Jul 2, 2024

This PR adds two additional OtherInfo pairs:

  • blueprint/X.Y.Z to mark a request as coming with the use of blueprint library
  • cmd/<name> to store CLI command name used for making the request

…n it is used as library

This PR adds two additional OtherInfo pairs:
* `blueprint/X.Y.Z` to mark a request as coming with the use of blueprint library
* `cmd/<name>` to store CLI command name used for making the request
Copy link

github-actions bot commented Jul 2, 2024

This PR breaks backwards compatibility for databrickslabs/ucx downstream. See build logs for more details.

Running from downstreams #82

Copy link

github-actions bot commented Jul 2, 2024

✅ 12/12 passed, 2 skipped, 36s total

Running from acceptance #149

@nfx nfx merged commit 11616d7 into main Jul 2, 2024
8 of 9 checks passed
@nfx nfx deleted the feat/user-agent-pass branch July 2, 2024 12:59
nfx added a commit to databrickslabs/ucx that referenced this pull request Jul 2, 2024
This PR adds `User-Agent` OtherInfo elements:
* `ucx/<version>` for all requests where UCX is imported as a library
* `cmd/install` for all installations/upgrades
* `cmd/<workflow>` for all managed job invocations

Relevant PRs:
- databrickslabs/lsql#206
- databrickslabs/blueprint#114
nfx added a commit that referenced this pull request Jul 5, 2024
* Added `databricks.labs.blueprint.paths.WorkspacePath` as `pathlib.Path` equivalent ([#115](#115)). This commit introduces the `databricks.labs.blueprint.paths.WorkspacePath` library, providing Python-native `pathlib.Path`-like interfaces to simplify working with Databricks Workspace paths. The library includes `WorkspacePath` and `WorkspacePathDuringTest` classes offering advanced functionality for handling user home folders, relative file paths, browser URLs, and file manipulation methods such as `read/write_text()`, `read/write_bytes()`, and `glob()`. This addition brings enhanced, Pythonic ways to interact with Databricks Workspace paths, including creating and moving files, managing directories, and generating browser-accessible URIs. Additionally, the commit includes updates to existing methods and introduces new fixtures for creating notebooks, accompanied by extensive unit tests to ensure reliability and functionality.
* Added propagation of `blueprint` version into `User-Agent` header when it is used as library ([#114](#114)). A new feature has been introduced in the library that allows for the propagation of the `blueprint` version and the name of the command line interface (CLI) command used in the `User-Agent` header when the library is utilized as a library. This feature includes the addition of two new pairs of `OtherInfo`: `blueprint/X.Y.Z` to indicate that the request is made using the `blueprint` library and `cmd/<name>` to store the name of the CLI command used for making the request. The implementation involves using the `with_user_agent_extra` function from `databricks.sdk.config` to set the user agent consistently with the Databricks CLI. Several changes have been made to the test file for `test_useragent.py` to include a new test case, `test_user_agent_is_propagated`, which checks if the `blueprint` version and the name of the command are correctly propagated to the `User-Agent` header. A context manager `http_fixture_server` has been added that creates an HTTP server with a custom handler, which extracts the `blueprint` version and the command name from the `User-Agent` header and stores them in the `user_agent` dictionary. The test case calls the `foo` command with a mocked `WorkspaceClient` instance and sets the `DATABRICKS_HOST` and `DATABRICKS_TOKEN` environment variables to test the propagation of the `blueprint` version and the command name in the `User-Agent` header. The test case then asserts that the `blueprint` version and the name of the command are present and correctly set in the `user_agent` dictionary.
* Bump actions/checkout from 4.1.6 to 4.1.7 ([#112](#112)). In this release, the version of the "actions/checkout" action used in the `Checkout Code` step of the acceptance workflow has been updated from 4.1.6 to 4.1.7. This update may include bug fixes, performance improvements, and new features, although specific changes are not mentioned in the commit message. The `Unshallow` step remains unchanged, continuing to fetch and clean up the repository's history. This update ensures that the latest enhancements from the "actions/checkout" action are utilized, aiming to improve the reliability and performance of the code checkout process in the GitHub Actions workflow. Software engineers should be aware of this update and its potential impact on their workflows.

Dependency updates:

 * Bump actions/checkout from 4.1.6 to 4.1.7 ([#112](#112)).
@nfx nfx mentioned this pull request Jul 5, 2024
nfx added a commit that referenced this pull request Jul 5, 2024
* Added `databricks.labs.blueprint.paths.WorkspacePath` as
`pathlib.Path` equivalent
([#115](#115)). This
commit introduces the `databricks.labs.blueprint.paths.WorkspacePath`
library, providing Python-native `pathlib.Path`-like interfaces to
simplify working with Databricks Workspace paths. The library includes
`WorkspacePath` and `WorkspacePathDuringTest` classes offering advanced
functionality for handling user home folders, relative file paths,
browser URLs, and file manipulation methods such as `read/write_text()`,
`read/write_bytes()`, and `glob()`. This addition brings enhanced,
Pythonic ways to interact with Databricks Workspace paths, including
creating and moving files, managing directories, and generating
browser-accessible URIs. Additionally, the commit includes updates to
existing methods and introduces new fixtures for creating notebooks,
accompanied by extensive unit tests to ensure reliability and
functionality.
* Added propagation of `blueprint` version into `User-Agent` header when
it is used as library
([#114](#114)). A new
feature has been introduced in the library that allows for the
propagation of the `blueprint` version and the name of the command line
interface (CLI) command used in the `User-Agent` header when the library
is utilized as a library. This feature includes the addition of two new
pairs of `OtherInfo`: `blueprint/X.Y.Z` to indicate that the request is
made using the `blueprint` library and `cmd/<name>` to store the name of
the CLI command used for making the request. The implementation involves
using the `with_user_agent_extra` function from `databricks.sdk.config`
to set the user agent consistently with the Databricks CLI. Several
changes have been made to the test file for `test_useragent.py` to
include a new test case, `test_user_agent_is_propagated`, which checks
if the `blueprint` version and the name of the command are correctly
propagated to the `User-Agent` header. A context manager
`http_fixture_server` has been added that creates an HTTP server with a
custom handler, which extracts the `blueprint` version and the command
name from the `User-Agent` header and stores them in the `user_agent`
dictionary. The test case calls the `foo` command with a mocked
`WorkspaceClient` instance and sets the `DATABRICKS_HOST` and
`DATABRICKS_TOKEN` environment variables to test the propagation of the
`blueprint` version and the command name in the `User-Agent` header. The
test case then asserts that the `blueprint` version and the name of the
command are present and correctly set in the `user_agent` dictionary.
* Bump actions/checkout from 4.1.6 to 4.1.7
([#112](#112)). In
this release, the version of the "actions/checkout" action used in the
`Checkout Code` step of the acceptance workflow has been updated from
4.1.6 to 4.1.7. This update may include bug fixes, performance
improvements, and new features, although specific changes are not
mentioned in the commit message. The `Unshallow` step remains unchanged,
continuing to fetch and clean up the repository's history. This update
ensures that the latest enhancements from the "actions/checkout" action
are utilized, aiming to improve the reliability and performance of the
code checkout process in the GitHub Actions workflow. Software engineers
should be aware of this update and its potential impact on their
workflows.

Dependency updates:

* Bump actions/checkout from 4.1.6 to 4.1.7
([#112](#112)).
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.

1 participant