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

Update Analytics #1994

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@
"api/docker-compose.yml"
],
"matchPackagePatterns": ["postgres"]
},
{
"description": "Don't upgrade Kaleido automatically in analytics code as it has breaking changes in minor versions",
"enabled": false,
"matchFileNames": [
"analytics/pyproject.toml",
"analytics/poetry.lock"
],
"matchPackagePatterns": ["kaleido"]
Comment on lines +131 to +138
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I saw this too 👍🏼

}
]
}
4 changes: 2 additions & 2 deletions analytics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ format: ## runs code formatting
@echo "=> Running code formatting"
@echo "============================="
$(POETRY) black src tests
$(POETRY) ruff --fix src tests
$(POETRY) ruff check --fix src tests
@echo "============================="
@echo "=> Code formatting complete"

format-check: ## runs code formatting checks
@echo "=> Running code formatting checks"
@echo "============================="
$(POETRY) black --check src tests
$(POETRY) ruff --fix --exit-non-zero-on-fix src tests
$(POETRY) ruff check src tests
@echo "============================="
@echo "=> All checks succeeded"

Expand Down
62 changes: 28 additions & 34 deletions analytics/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions analytics/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plotly = "^5.15.0"
pydantic = "^2.0.3"
python = "~3.13"
slack-sdk = "^3.23.0"
typer = { extras = ["all"], version = "^0.9.0" }
typer = { extras = ["all"], version = "^0.13.0" }
sqlalchemy = "^2.0.30"
psycopg = ">=3.0.7"
pydantic-settings = "^2.3.4"
Expand All @@ -32,7 +32,7 @@ mypy = "^1.4.1"
pylint = "^3.0.2"
pytest = "^8.0.0"
pytest-cov = "^5.0.0"
ruff = "^0.0.278"
ruff = "^0.7.0"
safety = "^3.0.0"

[build-system]
Expand All @@ -58,6 +58,10 @@ disable = [
]

[tool.ruff]
line-length = 100

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"ANN101", # missing type annotation for self
"ANN102", # missing type annotation for cls
Expand All @@ -70,9 +74,8 @@ ignore = [
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"TD003", # missing an issue link on TODO
"T201", # use of `print` detected
"FA102", # Adding "from __future__ import annotations" to any new-style type annotation
]
line-length = 100
select = ["ALL"]

[tool.pytest.ini_options]
filterwarnings = [
Expand Down
4 changes: 2 additions & 2 deletions analytics/src/analytics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging.config
from datetime import datetime
from pathlib import Path
from typing import Annotated, Optional
from typing import Annotated

import typer
from slack_sdk import WebClient
Expand Down Expand Up @@ -155,7 +155,7 @@ def calculate_deliverable_percent_complete(
show_results: Annotated[bool, SHOW_RESULTS_ARG] = False,
post_results: Annotated[bool, POST_RESULTS_ARG] = False,
output_dir: Annotated[str, OUTPUT_DIR_ARG] = "data",
include_status: Annotated[Optional[list[str]], STATUS_ARG] = None, # noqa: UP007
include_status: Annotated[list[str] | None, STATUS_ARG] = None,
) -> None:
"""Calculate percentage completion by deliverable."""
task_data = GitHubIssues.from_json(issue_file)
Expand Down
1 change: 1 addition & 0 deletions analytics/src/analytics/datasets/etl_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def load_from_json_file(cls, file_path: str) -> Self:
-------
Self:
An instance of the EtlDataset dataset class

"""
# load input datasets
df = load_json_data_as_df(
Expand Down
1 change: 1 addition & 0 deletions analytics/src/analytics/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def load_json_data_as_df(
-------
pd.DataFrame
Pandas dataframe with columns renamed to match the values of the column map

"""
# load json data from the local file
with open(file_path, encoding="utf-8") as f:
Expand Down
4 changes: 3 additions & 1 deletion analytics/src/analytics/etl/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class RoadmapConfig(BaseModel):
The name of the project field that stores the Quad value for a deliverable.
pillar_field
The name of the project field that stores the Pillar value for a deliverable.

"""

owner: str
Expand All @@ -77,6 +78,7 @@ class SprintBoardConfig(BaseModel):
The name of the project field that stores story points or estimates.
sprint_field
The name of the project field that stores the sprint value.

"""

owner: str
Expand Down Expand Up @@ -218,7 +220,7 @@ def populate_issue_lookup_table(
for i, issue in enumerate(issues):
try:
entry = IssueMetadata.model_validate(issue)
except ValidationError as err: # noqa: PERF203
except ValidationError as err:
logger.error("Error parsing row %d, skipped.", i) # noqa: TRY400
logger.debug("Error: %s", err)
continue
Expand Down
1 change: 1 addition & 0 deletions analytics/src/analytics/etl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def load_config(config_path: Path, schema: type[T]) -> T:
Returns
-------
An instance of the schema containing validated config data.

"""
with open(config_path) as f:
config_data = json.load(f)
Expand Down
1 change: 1 addition & 0 deletions analytics/src/analytics/metrics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def chart(self) -> Figure:
----
By deferring the self.plot_results() method invocation until the chart is
needed, we decrease the amount of time required to instantiate the class

"""
if not self._chart:
self._chart = self.plot_results()
Expand Down
1 change: 1 addition & 0 deletions analytics/src/analytics/metrics/percent_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def calculate(self) -> pd.DataFrame:
and a closed count column
4. Subtract closed count from total count to get open count
5. Divide closed count by total count to get percent complete

"""
# get total and closed counts per deliverable
df_total = self._get_count_by_deliverable(status="all")
Expand Down
2 changes: 2 additions & 0 deletions analytics/tests/ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Extend the ruff configuration in the pyproject.toml at the root of this package
extend = "../pyproject.toml"

[lint]
ignore = [
"ANN201", # missing return type
"PLR2004", # magic value used in comparison instead of constant
Expand Down