Skip to content

Commit bc8c697

Browse files
authored
Upgrade glean_parser to 1.20.1 (#827)
* Upgrade glean_parser to 1.20.0 * spellcheck * Fix sample app metrics.yaml * Upgrade to glean_parser 1.20.1 * Fix syntax * iso8601 only needed by earlier Pythons * Upgrade to 1.20.2 * Handle iso8601 as an optional dependency * spellcheck * Fix up CHANGELOG
1 parent 3e6b22a commit bc8c697

File tree

11 files changed

+104
-36
lines changed

11 files changed

+104
-36
lines changed

Diff for: .circleci/config.yml

+24
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,17 @@ jobs:
753753
- skip-if-doc-only
754754
- test-python
755755

756+
Python 3_5 tests minimum dependencies:
757+
docker:
758+
- image: circleci/python:3.5.9
759+
steps:
760+
- checkout
761+
- skip-if-doc-only
762+
- run:
763+
command: |
764+
echo "export GLEAN_PYDEPS=min" >> $BASH_ENV
765+
- test-python
766+
756767
Python 3_6 tests:
757768
docker:
758769
- image: circleci/python:3.6.9
@@ -779,6 +790,17 @@ jobs:
779790
- skip-if-doc-only
780791
- test-python
781792

793+
Python 3_8 tests minimum dependencies:
794+
docker:
795+
- image: circleci/python:3.8.2
796+
steps:
797+
- checkout
798+
- skip-if-doc-only
799+
- run:
800+
command: |
801+
echo "export GLEAN_PYDEPS=min" >> $BASH_ENV
802+
- test-python
803+
782804
Python Windows x86_64 tests:
783805
docker:
784806
- image: circleci/python:3.7.6
@@ -1049,9 +1071,11 @@ workflows:
10491071
branches:
10501072
only: master
10511073
- Python 3_5 tests
1074+
- Python 3_5 tests minimum dependencies
10521075
- Python 3_6 tests
10531076
- Python 3_7 tests
10541077
- Python 3_8 tests
1078+
- Python 3_8 tests minimum dependencies
10551079
- Python Windows x86_64 tests
10561080
- Python Windows i686 tests
10571081

Diff for: .dictionary

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 166 utf-8
1+
personal_ws-1.1 en 167 utf-8
22
AAR
33
AARs
44
APIs
@@ -67,6 +67,7 @@ aspell
6767
async
6868
autodetected
6969
backend
70+
backport
7071
barcode
7172
boolean
7273
booleans
@@ -115,6 +116,7 @@ lang
115116
latencies
116117
lfloor
117118
lifecycle
119+
linter
118120
linux
119121
logcat
120122
macOS

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55

66
[Full changelog](https://github.com/mozilla/glean/compare/v28.0.0...master)
77

8+
* General:
9+
* The version of glean_parser has been upgraded to v1.20.2:
10+
* **Breaking change:** glinter errors found during code generation will now return an error code.
11+
* `glean_parser` now produces a linter warning when `user` lifetime metrics are set to expire. See [bug 1604854](https://bugzilla.mozilla.org/show_bug.cgi?id=1604854) for additional context.
812
* Python:
913
* BUGFIX: Fixed a race condition in the `atexit` handler, that would have resulted in the message "No database found". See [bug 1634310](https://bugzilla.mozilla.org/show_bug.cgi?id=1634310).
14+
* The minimum versions of many secondary dependencies have been lowered to make the Glean SDK compatible with more environments.
15+
* Dependencies that depend on the version of Python being used are now specified using the `Declaring platform specific dependencies syntax in setuptools <https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies>`__. This means that more recent versions of dependencies are likely to be installed on Python 3.6 and later, and unnecessary backport libraries won't be installed on more recent Python versions.
1016

1117
# v28.0.0 (2020-04-23)
1218

Diff for: Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ help:
55
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
66

77
GLEAN_PYENV := $(shell python3 -c "import sys; print('glean-core/python/.venv' + '.'.join(str(x) for x in sys.version_info[:2]))")
8+
GLEAN_PYDEPS := ${GLEAN_PYDEPS}
89

910
# Setup environments
1011

@@ -15,6 +16,11 @@ $(GLEAN_PYENV)/bin/python3:
1516
python3 -m venv $(GLEAN_PYENV)
1617
$(GLEAN_PYENV)/bin/pip install --upgrade pip
1718
$(GLEAN_PYENV)/bin/pip install -r glean-core/python/requirements_dev.txt
19+
bash -c "if [ \"$(GLEAN_PYDEPS)\" == \"min\" ]; then \
20+
$(GLEAN_PYENV)/bin/pip install requirements-builder; \
21+
$(GLEAN_PYENV)/bin/requirements-builder --level=min glean-core/python/setup.py > min_requirements.txt; \
22+
$(GLEAN_PYENV)/bin/pip install -r min_requirements.txt; \
23+
fi"
1824
# black isn't installable on Python 3.5, but we can do without it
1925
$(GLEAN_PYENV)/bin/pip install black || true
2026

Diff for: docs/dev/python/setting-up-python-build-environment.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ pip install -r requirements_dev.txt
6767

6868
The default location of the virtual environment used by the make file is `glean-core/python/.venvX.Y`, where `X.Y` is the version of Python in use. This makes it possible to build and test for multiple versions of Python in the same checkout.
6969

70-
> *Note:* If you wish to change the location of the virtual environment that the `Makefile` uses, pass the `GLEAN_PYENV` environment variable: `make test-python GLEAN_PYENV=mypyenv`.
70+
> *Note:* If you wish to change the location of the virtual environment that the `Makefile` uses, pass the `GLEAN_PYENV` environment variable: `make python-setup GLEAN_PYENV=mypyenv`.
71+
72+
By default, the `Makefile` installs the latest version available of each of Glean's dependencies. If you wish to install the minimum required versions instead, (useful primarily to ensure that Glean doesn't unintentionally use newer APIs in its dependencies) pass the `GLEAN_PYDEPS=min` environment variable: `make python-setup GLEAN_PYDEPS=min`.
7173

7274
## Build the Python bindings
7375

Diff for: glean-core/ios/sdk_generator.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
set -e
2727

28-
GLEAN_PARSER_VERSION=1.19.0
28+
GLEAN_PARSER_VERSION=1.20.2
2929

3030
# CMDNAME is used in the usage text below.
3131
# shellcheck disable=SC2034

Diff for: glean-core/python/glean/metrics/datetime.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55

66
import datetime
7+
import sys
78
from typing import List, Optional
89

910

10-
import iso8601 # type: ignore
11-
12-
1311
from .. import _ffi
1412
from .._dispatcher import Dispatcher
1513
from ..testing import ErrorType
@@ -19,6 +17,12 @@
1917
from .timeunit import TimeUnit
2018

2119

20+
if sys.version_info < (3, 7):
21+
import iso8601 # type: ignore
22+
else:
23+
iso8601 = None
24+
25+
2226
class DatetimeMetricType:
2327
"""
2428
This implements the developer facing API for recording datetime metrics.
@@ -144,7 +148,12 @@ def test_get_value(self, ping_name: Optional[str] = None) -> datetime.datetime:
144148
Returns:
145149
value (datetime.datetime): value of the stored metric.
146150
"""
147-
return iso8601.parse_date(self.test_get_value_as_str(ping_name))
151+
if sys.version_info < (3, 7):
152+
return iso8601.parse_date(self.test_get_value_as_str(ping_name))
153+
else:
154+
return datetime.datetime.fromisoformat(
155+
self.test_get_value_as_str(ping_name)
156+
)
148157

149158
def test_get_num_recorded_errors(
150159
self, error_type: ErrorType, ping_name: Optional[str] = None

Diff for: glean-core/python/setup.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
version = parsed_toml["package"]["version"]
4848

4949
requirements = [
50-
"cffi==1.13.1",
51-
"glean_parser==1.19.0",
52-
"iso8601==0.1.12",
50+
"cffi>=1",
51+
"glean_parser==1.20.2",
52+
"iso8601>=0.1.10; python_version<='3.6'",
5353
]
5454

5555
setup_requirements = []
@@ -75,7 +75,14 @@
7575
shutil.copyfile("../ffi/glean.h", "glean/glean.h")
7676
shutil.copyfile("../metrics.yaml", "glean/metrics.yaml")
7777
shutil.copyfile("../pings.yaml", "glean/pings.yaml")
78-
shutil.copyfile(shared_object_build_dir + shared_object, "glean/" + shared_object)
78+
# When running inside of `requirements-builder`, the Rust shared object may not
79+
# yet exist, so ignore the exception when trying to copy it. Under normal
80+
# circumstances, this will still show up as an error when running the `build`
81+
# command as a missing `package_data` file.
82+
try:
83+
shutil.copyfile(shared_object_build_dir + shared_object, "glean/" + shared_object)
84+
except FileNotFoundError:
85+
pass
7986

8087

8188
class BinaryDistribution(Distribution):

Diff for: gradle-plugin/src/main/groovy/mozilla/telemetry/glean-gradle-plugin/GleanGradlePlugin.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class GleanMetricsYamlTransform extends ArtifactTransform {
3434
@SuppressWarnings("GrPackage")
3535
class GleanPlugin implements Plugin<Project> {
3636
// The version of glean_parser to install from PyPI.
37-
private String GLEAN_PARSER_VERSION = "1.19.0"
37+
private String GLEAN_PARSER_VERSION = "1.20.2"
3838
// The version of Miniconda is explicitly specified.
3939
// Miniconda3-4.5.12 is known to not work on Windows.
4040
private String MINICONDA_VERSION = "4.5.11"

Diff for: samples/android/app/metrics.yaml

+22-16
Original file line numberDiff line numberDiff line change
@@ -13,94 +13,98 @@ $schema: moz://mozilla.org/schemas/glean/metrics/1-0-0
1313
browser.engagement:
1414
click:
1515
type: event
16-
description: >
16+
description: |
1717
Just testing events
1818
bugs:
1919
- https://bugzilla.mozilla.org/123456789
2020
data_reviews:
21-
- N/A
21+
- N/A
2222
notification_emails:
2323
2424
extra_keys:
2525
key1:
2626
description: "This is key one"
2727
key2:
2828
description: "This is key two"
29-
expires: 2100-01-01
30-
29+
expires: 2100-01-01
30+
3131
event_no_keys:
3232
type: event
33-
description: >
33+
description: |
3434
Just testing events without keys
3535
bugs:
3636
- https://bugzilla.mozilla.org/123456789
3737
data_reviews:
38-
- N/A
38+
- N/A
3939
notification_emails:
4040
4141
expires: 2100-01-01
4242

4343
basic:
4444
os:
4545
type: string
46-
description: >
46+
description: |
4747
The name of the os
4848
bugs:
4949
- https://bugzilla.mozilla.org/123456789
5050
data_reviews:
51-
- N/A
51+
- N/A
5252
notification_emails:
5353
5454
expires: 2100-01-01
5555

5656
test:
5757
string_list:
5858
type: string_list
59-
description: >
59+
description: |
6060
Testing StringList ping
6161
send_in_pings:
6262
- test-string-list
6363
lifetime: user
6464
bugs:
6565
- https://bugzilla.mozilla.org/123456789
6666
data_reviews:
67-
- N/A
67+
- N/A
6868
notification_emails:
6969
7070
expires: 2100-01-01
71+
no_lint:
72+
- USER_LIFETIME_EXPIRATION
7173

7274
counter:
7375
type: counter
74-
description: >
76+
description: |
7577
Testing counter
7678
send_in_pings:
7779
- test-string-list
7880
lifetime: user
7981
bugs:
8082
- https://bugzilla.mozilla.org/123456789
8183
data_reviews:
82-
- N/A
84+
- N/A
8385
notification_emails:
8486
8587
expires: 2100-01-01
88+
no_lint:
89+
- USER_LIFETIME_EXPIRATION
8690

8791
timespan:
8892
type: timespan
89-
description: >
93+
description: |
9094
Testing a timespan
9195
time_unit: microsecond
9296
lifetime: application
9397
bugs:
9498
- https://bugzilla.mozilla.org/1508948
9599
data_reviews:
96-
- N/A
100+
- N/A
97101
notification_emails:
98102
99103
expires: 2100-01-01
100104

101105
is_started:
102106
type: boolean
103-
description: >
107+
description: |
104108
Testing boolean
105109
send_in_pings:
106110
- baseline
@@ -112,11 +116,13 @@ test:
112116
notification_emails:
113117
114118
expires: 2100-01-01
119+
no_lint:
120+
- BASELINE_PING
115121

116122
custom:
117123
counter:
118124
type: counter
119-
description: >
125+
description: |
120126
A custom counter that goes on a custom ping
121127
lifetime: ping
122128
send_in_pings:

0 commit comments

Comments
 (0)