Skip to content

Commit

Permalink
Relax glean_parser version requirement to "all compatible releases"
Browse files Browse the repository at this point in the history
In pip `~=V.N` is equivalent to `>= V.N, == V.*`
So we essentially allow everything from the specified minor version
upwards until the next major version (excluded).
As long as glean_parser is careful to not introduce breaking changes
before that this will simplify work a lot by allowing small bug fixes
without requiring subsequent Glean releases to bump versions all the
time.
  • Loading branch information
badboy committed Jun 14, 2022
1 parent e334bb0 commit 264bd63
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ python-docs: build-python ## Build the Python documentation
.PHONY: docs rust-docs swift-docs

metrics-docs: python-setup ## Build the internal metrics documentation
$(GLEAN_PYENV)/bin/pip install glean_parser==6.1.1
$(GLEAN_PYENV)/bin/pip install glean_parser~=6.1
$(GLEAN_PYENV)/bin/glean_parser translate --allow-reserved \
-f markdown \
-o ./docs/user/user/collected-metrics \
Expand Down
9 changes: 5 additions & 4 deletions bin/update-glean-parser-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ if [ -z "$1" ]; then
fi

NEW_VERSION="$1"
NEW_VERSION_MAJOR_MINOR="$(echo "$NEW_VERSION" | awk -F'.' '{print $1"."$2}')"

# Update the version in glean-core/ios/sdk_generator.sh
FILE=glean-core/ios/sdk_generator.sh
run $SED -i.bak -E \
-e "s/^GLEAN_PARSER_VERSION=[0-9.]+/GLEAN_PARSER_VERSION=${NEW_VERSION}/" \
-e "s/^GLEAN_PARSER_VERSION=[0-9.]+/GLEAN_PARSER_VERSION=${NEW_VERSION_MAJOR_MINOR}/" \
"${WORKSPACE_ROOT}/${FILE}"
run rm "${WORKSPACE_ROOT}/${FILE}.bak"

# Update the version in glean-core/python/setup.py
FILE=glean-core/python/setup.py
run $SED -i.bak -E \
-e "s/\"glean_parser==[0-9.]+\"/\"glean_parser==${NEW_VERSION}\"/" \
-e "s/\"glean_parser~=[0-9.]+\"/\"glean_parser~=${NEW_VERSION_MAJOR_MINOR}\"/" \
"${WORKSPACE_ROOT}/${FILE}"
run rm "${WORKSPACE_ROOT}/${FILE}.bak"

Expand All @@ -52,7 +53,7 @@ run rm "${WORKSPACE_ROOT}/${FILE}.bak"
# update the version in gradle-plugin/src/main/groovy/mozilla/telemetry/glean-gradle-plugin/GleanGradlePlugin.groovy
FILE=gradle-plugin/src/main/groovy/mozilla/telemetry/glean-gradle-plugin/GleanGradlePlugin.groovy
run $SED -i.bak -E \
-e "s/GLEAN_PARSER_VERSION = \"[0-9.]+\"/GLEAN_PARSER_VERSION = \"${NEW_VERSION}\"/" \
-e "s/GLEAN_PARSER_VERSION = \"[0-9.]+\"/GLEAN_PARSER_VERSION = \"${NEW_VERSION_MAJOR_MINOR}\"/" \
"${WORKSPACE_ROOT}/${FILE}"
run rm "${WORKSPACE_ROOT}/${FILE}.bak"

Expand All @@ -66,6 +67,6 @@ run rm "${WORKSPACE_ROOT}/${FILE}.bak"
# update the version in the Makefile
FILE=Makefile
run $SED -i.bak -E \
-e "s/glean_parser==[0-9.]+/glean_parser==${NEW_VERSION}/" \
-e "s/glean_parser~=[0-9.]+/glean_parser~=${NEW_VERSION_MAJOR_MINOR}/" \
"${WORKSPACE_ROOT}/${FILE}"
run rm "${WORKSPACE_ROOT}/${FILE}.bak"
6 changes: 3 additions & 3 deletions docs/user/user/collected-metrics/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

> If you are looking for the metrics collected by Glean.js,
> refer to the documentation over on the [`@mozilla/glean.js`](https://github.com/mozilla/glean.js/blob/main/docs/reference/metrics.md) repository.
<!-- AUTOGENERATED BY glean_parser. DO NOT EDIT. -->
<!-- AUTOGENERATED BY glean_parser v6.0.1. DO NOT EDIT. -->
# Metrics

Expand Down Expand Up @@ -161,7 +161,7 @@ In addition to those built-in metrics, the following metrics are added to the pi
| --- | --- | --- | --- | --- | --- | --- |
| glean.database.size |[memory_distribution](https://mozilla.github.io/glean/book/user/metrics/memory_distribution.html) |The size of the database file at startup. |[Bug 1656589](https://bugzilla.mozilla.org/show_bug.cgi?id=1656589#c7)||never |1 |
| glean.error.io |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The number of times we encountered an IO error when writing a pending ping to disk. |[Bug 1686233](https://bugzilla.mozilla.org/show_bug.cgi?id=1686233#c2)||never |1 |
| glean.error.preinit_tasks_overflow |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The number of tasks queued in the pre-initialization buffer. Only sent if the buffer overflows. |[Bug 1609482](https://bugzilla.mozilla.org/show_bug.cgi?id=1609482#c3)||never |1 |
| glean.error.preinit_tasks_overflow |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The number of tasks that overflowed the pre-initialization buffer. Only sent if the buffer ever overflows. In Version 0 this reported the total number of tasks enqueued. |[Bug 1609482](https://bugzilla.mozilla.org/show_bug.cgi?id=1609482#c3)||never |1 |
| glean.upload.deleted_pings_after_quota_hit |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The number of pings deleted after the quota for the size of the pending pings directory or number of files is hit. Since quota is only calculated for the pending pings directory, and deletion request ping live in a different directory, deletion request pings are never deleted. |[Bug 1601550](https://bugzilla.mozilla.org/show_bug.cgi?id=1601550#c3)||never |1 |
| glean.upload.discarded_exceeding_pings_size |[memory_distribution](https://mozilla.github.io/glean/book/user/metrics/memory_distribution.html) |The size of pings that exceeded the maximum ping size allowed for upload. |[Bug 1597761](https://bugzilla.mozilla.org/show_bug.cgi?id=1597761#c10)||never |1 |
| glean.upload.pending_pings |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The total number of pending pings at startup. This does not include deletion-request pings. |[Bug 1665041](https://bugzilla.mozilla.org/show_bug.cgi?id=1665041#c23)||never |1 |
Expand All @@ -173,5 +173,5 @@ In addition to those built-in metrics, the following metrics are added to the pi

Data categories are [defined here](https://wiki.mozilla.org/Firefox/Data_Collection).

<!-- AUTOGENERATED BY glean_parser. DO NOT EDIT. -->
<!-- AUTOGENERATED BY glean_parser v6.0.1. DO NOT EDIT. -->

4 changes: 2 additions & 2 deletions glean-core/ios/sdk_generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

set -e

GLEAN_PARSER_VERSION=6.1.1
GLEAN_PARSER_VERSION=6.1

# CMDNAME is used in the usage text below.
# shellcheck disable=SC2034
Expand Down Expand Up @@ -159,7 +159,7 @@ VENVDIR="${SOURCE_ROOT}/.venv"
# We need at least pip 20.3 for Big Sur support, see https://pip.pypa.io/en/stable/news/#id48
# Latest pip is 21.0.1
"${VENVDIR}"/bin/pip install "pip>=20.3"
"${VENVDIR}"/bin/pip install --upgrade glean_parser==$GLEAN_PARSER_VERSION
"${VENVDIR}"/bin/pip install --upgrade "glean_parser~=$GLEAN_PARSER_VERSION"

# Run the glinter
# Turn its warnings into warnings visible in Xcode (but don't do for the success message)
Expand Down
7 changes: 5 additions & 2 deletions glean-core/python/glean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@


GLEAN_PARSER_VERSION = "6.1.1"
parser_version = VersionInfo.parse(GLEAN_PARSER_VERSION)
parser_version_next_major = parser_version.bump_major()


if glean_parser.__version__ != GLEAN_PARSER_VERSION:
current_parser = VersionInfo.parse(glean_parser.__version__)
if current_parser < parser_version or current_parser >= parser_version_next_major:
warnings.warn(
f"glean_sdk expected glean_parser v{GLEAN_PARSER_VERSION}, "
f"glean_sdk expected glean_parser ~= v{GLEAN_PARSER_VERSION}, "
f"found v{glean_parser.__version__}",
Warning,
)
Expand Down
1 change: 1 addition & 0 deletions glean-core/python/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pip
pytest-localserver==0.5.1
pytest-runner==5.3.1
pytest==7.0.1
semver==2.13.0
setuptools-git==1.2
twine==3.8.0
types-pkg_resources==0.1.3
Expand Down
3 changes: 2 additions & 1 deletion glean-core/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@

requirements = [
"cffi>=1.13.0",
"glean_parser==6.1.1",
"semver>=2.13.0",
"glean_parser~=6.1",
]

setup_requirements = ["cffi>=1.13.0"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GleanMetricsYamlTransform extends ArtifactTransform {
@SuppressWarnings("GrPackage")
class GleanPlugin implements Plugin<Project> {
// The version of glean_parser to install from PyPI.
private String GLEAN_PARSER_VERSION = "6.1.1"
private String GLEAN_PARSER_VERSION = "6.1"
// The version of Miniconda is explicitly specified.
// Miniconda3-4.5.12 is known to not work on Windows.
private String MINICONDA_VERSION = "4.5.11"
Expand Down Expand Up @@ -454,7 +454,7 @@ except:
if (parserVersion.matches("git.+")) {
conda "Miniconda3", "Miniconda3-${MINICONDA_VERSION}", "64", [parserVersion]
} else {
conda "Miniconda3", "Miniconda3-${MINICONDA_VERSION}", "64", ["glean_parser==${parserVersion}"]
conda "Miniconda3", "Miniconda3-${MINICONDA_VERSION}", "64", ["glean_parser~=${parserVersion}"]
}
}
File envDir = new File(
Expand Down

0 comments on commit 264bd63

Please sign in to comment.