Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1b9dd9b
first draft
danielkberry Jul 31, 2024
9957413
clean up typing for experiment.py
danielkberry Jul 31, 2024
5bd1bdf
ruff
danielkberry Jul 31, 2024
c2c7cbb
added some tests
danielkberry Jul 31, 2024
52c6087
dedent to lint
danielkberry Aug 1, 2024
404be93
added unit tests
danielkberry Aug 1, 2024
bc40cf1
more tests
danielkberry Aug 1, 2024
d22c901
more unit tests
danielkberry Aug 1, 2024
91a94d6
Update pyproject.toml
danielkberry Aug 1, 2024
9e653e5
Update pyproject.toml
danielkberry Aug 1, 2024
884cab0
Update pyproject.toml
danielkberry Aug 1, 2024
b6a5f17
Update pyproject.toml
danielkberry Aug 1, 2024
aa9f025
cleanup
danielkberry Aug 1, 2024
a9618d7
Merge branch 'groupid_aggregation' of github.com:mozilla/mozanalysis …
danielkberry Aug 1, 2024
c799236
more cleanup, additional test
danielkberry Aug 1, 2024
380b00d
refactor, AnalysisUnit -> ExperimentalUnit
danielkberry Aug 1, 2024
fee8994
refactor enum levels
danielkberry Aug 1, 2024
aaf5033
update docstring
danielkberry Aug 1, 2024
40a3701
Merge branch 'main' into groupid_aggregation
danielkberry Aug 1, 2024
d4fdbe1
combined client/group query strings into one, added check for downsam…
danielkberry Aug 1, 2024
11aee4e
Update src/mozanalysis/metrics.py
danielkberry Aug 2, 2024
5a52dd5
Update src/mozanalysis/metrics.py
danielkberry Aug 2, 2024
f3d76dd
Update src/mozanalysis/experiment.py
danielkberry Aug 2, 2024
9e03d86
Update src/mozanalysis/experiment.py
danielkberry Aug 2, 2024
4441478
cleanup
danielkberry Aug 2, 2024
a64b250
rename unit from GROUP to PROFILE_GROUP
danielkberry Aug 2, 2024
abb4855
stricter typing, eliminates unexpected runtype type differences
danielkberry Aug 2, 2024
519f51c
linting
danielkberry Aug 2, 2024
bcf9f2f
mypy validation for metrics.py
danielkberry Aug 2, 2024
37be293
ExperimentalUnit -> AnalysisUnit
danielkberry Aug 5, 2024
78b0b41
make string multiline
danielkberry Aug 5, 2024
20d81e2
change timelimits analysis windows type
danielkberry Aug 5, 2024
cf08094
TimeSeriesResult analysis window parameter match TimeSeries
danielkberry Aug 5, 2024
c80119c
Update metrics.py
danielkberry Aug 8, 2024
2dda0b9
Merge branch 'main' into groupid_aggregation
danielkberry Aug 20, 2024
4ddaee7
update metric-config-parser
danielkberry Aug 20, 2024
4b2fc04
import AnalysisUnit from metric-config-parser
danielkberry Aug 20, 2024
cf0f514
update test
danielkberry Aug 20, 2024
bb9af58
circle's ruff out of sync with dependencies
danielkberry Aug 20, 2024
10d8a1d
ruff fix
danielkberry Aug 20, 2024
c46e725
missed .value
danielkberry Aug 20, 2024
1f41806
Update metrics.py
danielkberry Aug 22, 2024
b8ec995
removed analysis_unit converter
danielkberry Aug 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@ test_settings: &test_settings
chmod +x codecov
./codecov -F "$(basename $PWD | sed s/[^a-z]/_/g)"



####################
# Jobs: see https://circleci.com/docs/2.0/jobs-steps/
####################

version: 2
jobs:

py310:
<<: *test_settings
docker:
Expand All @@ -44,12 +41,12 @@ jobs:
docker:
- image: cimg/python:3.10
steps:
- checkout
- run:
name: Run linting
command: |
pip install ruff
ruff check src/ tests/
- checkout
- run:
name: Run linting
command: |
pip install -r requirements.txt
Comment thread
mikewilli marked this conversation as resolved.
ruff check src/ tests/

# Runs when the repository is tagged for release; see the workflows section
# below for trigger logic.
Expand Down Expand Up @@ -133,7 +130,7 @@ workflows:
- deploy:
filters:
tags:
only: /[0-9]{4}.[0-9]{1,2}.[0-9]+/ # Calver: YYYY.M.MINOR
only: /[0-9]{4}.[0-9]{1,2}.[0-9]+/ # Calver: YYYY.M.MINOR
branches:
# Ignore all branches; this workflow should only run for tags.
ignore: /.*/
2 changes: 1 addition & 1 deletion requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ more-itertools==10.4.0
# -c requirements.txt
# jaraco-classes
# jaraco-functools
mozilla-metric-config-parser==2024.7.1
mozilla-metric-config-parser==2024.8.1
# via
# -c requirements.txt
# mozanalysis
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,9 @@ more-itertools==10.4.0 \
# -r requirements-dev.in
# jaraco-classes
# jaraco-functools
mozilla-metric-config-parser==2024.7.1 \
--hash=sha256:07ba32624cb9a38662bdff259dd4ec385bdc8ca4500b461d8a9025a736a25c6b \
--hash=sha256:ad5169b4cec7b0fa013b3136584b7ee3d9b8a6a807d2eb71e5d9f269517f9d22
mozilla-metric-config-parser==2024.8.1 \
--hash=sha256:49fb6e67367809e3750108246e50dc1e68778564c2c158ba26bd4835b0b9c89c \
--hash=sha256:cadc4ba9fb8399be0b857abb4bdd1f12ff1943159463fec0d128b71b2e72b554
# via -r requirements-dev.in
mozilla-nimbus-schemas==2023.10.3 \
--hash=sha256:8771344a63b0d197dbebd8d7955ce8034d0f5063a13899f4da7d8a99803a76da \
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ more-itertools==10.4.0
# via
# jaraco-classes
# jaraco-functools
mozilla-metric-config-parser==2024.7.1
mozilla-metric-config-parser==2024.8.1
# via mozanalysis
mozilla-nimbus-schemas==2023.10.3
# via mozilla-metric-config-parser
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,9 @@ more-itertools==10.4.0 \
# -r requirements.in
# jaraco-classes
# jaraco-functools
mozilla-metric-config-parser==2024.7.1 \
--hash=sha256:07ba32624cb9a38662bdff259dd4ec385bdc8ca4500b461d8a9025a736a25c6b \
--hash=sha256:ad5169b4cec7b0fa013b3136584b7ee3d9b8a6a807d2eb71e5d9f269517f9d22
mozilla-metric-config-parser==2024.8.1 \
--hash=sha256:49fb6e67367809e3750108246e50dc1e68778564c2c158ba26bd4835b0b9c89c \
--hash=sha256:cadc4ba9fb8399be0b857abb4bdd1f12ff1943159463fec0d128b71b2e72b554
# via -r requirements.in
mozilla-nimbus-schemas==2023.10.3 \
--hash=sha256:8771344a63b0d197dbebd8d7955ce8034d0f5063a13899f4da7d8a99803a76da \
Expand Down
55 changes: 20 additions & 35 deletions src/mozanalysis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

from metric_config_parser.config import ConfigCollection

from mozanalysis.metrics import DataSource, Metric
from mozanalysis.segments import Segment, SegmentDataSource

METRIC_HUB_JETSTREAM_REPO = "https://github.com/mozilla/metric-hub/tree/main/jetstream"


Expand Down Expand Up @@ -68,12 +71,11 @@ def check_configs_for_app(self, app_name: str) -> bool:
return True
return False

def get_metric(self, metric_slug: str, app_name: str):
def get_metric(self, metric_slug: str, app_name: str) -> Metric:
"""Load a metric definition for the given app.

Returns a :class:`mozanalysis.metrics.Metric` instance.
"""
from mozanalysis.metrics import Metric

metric_definition = self.configs.get_metric_definition(metric_slug, app_name)
if metric_definition is None:
Expand All @@ -100,12 +102,11 @@ def get_metric(self, metric_slug: str, app_name: str):
app_name=app_name,
)

def get_data_source(self, data_source_slug: str, app_name: str):
def get_data_source(self, data_source_slug: str, app_name: str) -> DataSource:
"""Load a data source definition for the given app.

Returns a :class:`mozanalysis.metrics.DataSource` instance.
"""
from mozanalysis.metrics import DataSource

data_source_definition = self.configs.get_data_source_definition(
data_source_slug, app_name
Expand All @@ -120,26 +121,13 @@ def get_data_source(self, data_source_slug: str, app_name: str):
f"Could not find application {app_name}, so data source {data_source_slug} could not be resolved" # noqa:E501
)

return DataSource(
name=data_source_definition.name,
from_expr=data_source_definition.from_expression,
client_id_column=data_source_definition.client_id_column,
submission_date_column=data_source_definition.submission_date_column,
experiments_column_type=(
None
if data_source_definition.experiments_column_type == "none"
else data_source_definition.experiments_column_type
),
default_dataset=data_source_definition.default_dataset,
app_name=app_name,
)
return DataSource.from_mcp_data_source(data_source_definition, app_name)

def get_segment(self, segment_slug: str, app_name: str):
def get_segment(self, segment_slug: str, app_name: str) -> Segment:
"""Load a segment definition for the given app.

Returns a :class:`mozanalysis.segments.Segment` instance.
"""
from mozanalysis.segments import Segment

segment_definition = self.configs.get_segment_definition(segment_slug, app_name)
if segment_definition is None:
Expand All @@ -165,12 +153,13 @@ def get_segment(self, segment_slug: str, app_name: str):
app_name=app_name,
)

def get_segment_data_source(self, data_source_slug: str, app_name: str):
def get_segment_data_source(
self, data_source_slug: str, app_name: str
) -> SegmentDataSource:
"""Load a segment data source definition for the given app.

Returns a :class:`mozanalysis.segments.SegmentDataSource` instance.
"""
from mozanalysis.segments import SegmentDataSource

data_source_definition = self.configs.get_segment_data_source_definition(
data_source_slug, app_name
Expand All @@ -196,7 +185,9 @@ def get_segment_data_source(self, data_source_slug: str, app_name: str):
app_name=app_name,
)

def get_outcome_metric(self, metric_slug: str, outcome_slug: str, app_name: str):
def get_outcome_metric(
self, metric_slug: str, outcome_slug: str, app_name: str
) -> Metric:
"""Load a metric definition from an outcome defined for the given app.

Parametrized metrics are not supported, since they may not be defined outside
Expand Down Expand Up @@ -230,18 +221,21 @@ class MinimalConfiguration:
summaries = metric_definition.resolve(outcome_spec, conf, self.configs)
metric = summaries[0].metric

if metric.data_source is None:
raise ValueError(f"Unable to resolve DataSource for Metric {metric.name}")

return Metric(
name=metric.name,
select_expr=metric.select_expression,
friendly_name=metric.friendly_name,
description=metric.description,
data_source=metric.data_source,
data_source=DataSource.from_mcp_data_source(metric.data_source, app_name),
bigger_is_better=metric.bigger_is_better,
)

def get_outcome_data_source(
self, data_source_slug: str, outcome_slug: str, app_name: str
):
) -> DataSource:
"""Load a data source definition from an outcome defined for the given app.

Returns a :class:`mozanalysis.metrics.DataSource` instance.
Expand All @@ -266,17 +260,8 @@ def get_outcome_data_source(
+ f" in outcome {outcome_slug}"
)

return DataSource(
name=data_source_definition.name,
from_expr=data_source_definition.from_expression,
client_id_column=data_source_definition.client_id_column,
submission_date_column=data_source_definition.submission_date_column,
experiments_column_type=(
None
if data_source_definition.experiments_column_type == "none"
else data_source_definition.experiments_column_type
),
default_dataset=data_source_definition.default_dataset,
return DataSource.from_mcp_data_source(
data_source_definition, app_name=app_name
)


Expand Down
Loading