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

Complete the new TA pipeline implementations #1033

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion database/models/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Upload(CodecovBaseModel, MixinBaseClass):
upload_type_id = Column(types.Integer)

@cached_property
def flag_names(self):
def flag_names(self) -> list[str]:
return [f.flag_name for f in self.flags]


Expand Down
16 changes: 16 additions & 0 deletions database/tests/factories/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
Flake,
RepositoryFlag,
Test,
TestInstance,
TestResultReportTotals,
)
from database.tests.factories.core import (
CompareCommitFactory,
ReportFactory,
RepositoryFactory,
UploadFactory,
)


Expand Down Expand Up @@ -43,6 +45,20 @@ class Meta:
repository = factory.SubFactory(RepositoryFactory)


class TestInstanceFactory(factory.Factory):
class Meta:
model = TestInstance

test = factory.SubFactory(TestFactory)
upload = factory.SubFactory(UploadFactory)

outcome = "pass"
duration_seconds = 1.5
commitid = factory.SelfAttribute("upload.report.commit.commitid")
branch = factory.SelfAttribute("upload.report.commit.branch")
repoid = factory.SelfAttribute("upload.report.commit.repository.repoid")


class FlakeFactory(factory.Factory):
class Meta:
model = Flake
Expand Down
13 changes: 13 additions & 0 deletions django_scaffold/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@
if "timeseries" in DATABASES:
DATABASES["timeseries"]["AUTOCOMMIT"] = False

if "test_analytics" in DATABASES:
DATABASES["test_analytics"]["AUTOCOMMIT"] = False

IS_DEV = os.getenv("RUN_ENV") == "DEV"
IS_ENTERPRISE = os.getenv("RUN_ENV") == "ENTERPRISE"

GCS_BUCKET_NAME = get_config("services", "minio", "bucket", default="codecov")

BIGQUERY_WRITE_ENABLED = (
get_config("services", "bigquery", "write_enabled", default=False)
and "test_analytics" in DATABASES
)

BIGQUERY_READ_ENABLED = (
get_config("services", "bigquery", "read_enabled", default=False)
and "test_analytics" in DATABASES
)
# Application definition
INSTALLED_APPS = [
# dependencies
Expand All @@ -40,6 +52,7 @@
"shared.django_apps.profiling",
"shared.django_apps.reports",
"shared.django_apps.staticanalysis",
"shared.django_apps.test_analytics",
]

TELEMETRY_VANILLA_DB = "default"
Expand Down
8 changes: 4 additions & 4 deletions generated_proto/testrun/ta_testrun_pb2.py

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

5 changes: 5 additions & 0 deletions protobuf/ta_testrun.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ message TestRun {
PASSED = 0;
FAILED = 1;
SKIPPED = 2;
FLAKY_FAILED = 3;
}

optional Outcome outcome = 6;
Expand All @@ -27,4 +28,8 @@ message TestRun {

optional string filename = 14;
optional string framework = 15;

optional int64 upload_id = 16;
optional bytes flags_hash = 17;
optional bytes test_id = 18;
}
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ grpcio>=1.66.2
httpx
jinja2>=3.1.3
lxml>=5.3.0
mmh3>=5.0.1
mock
multidict>=6.1.0
openai
Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ markupsafe==2.1.3
# via jinja2
minio==7.1.13
# via shared
mmh3==4.0.1
# via shared
mmh3==5.0.1
# via
# -r requirements.in
# shared
mock==4.0.3
# via -r requirements.in
monotonic==1.5
Expand Down
18 changes: 13 additions & 5 deletions services/bigquery.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from types import ModuleType
from typing import Dict, List, cast
from typing import Dict, List, Sequence, cast

import polars as pl
from google.api_core import retry
Expand Down Expand Up @@ -108,7 +108,17 @@ def write(

self.write_client.batch_commit_write_streams(batch_commit_write_streams_request)

def query(self, query: str, params: dict | None = None) -> List[Dict]:
def query(
self,
query: str,
params: Sequence[
bigquery.ScalarQueryParameter
| bigquery.RangeQueryParameter
| bigquery.ArrayQueryParameter
| bigquery.StructQueryParameter
]
| None = None,
) -> List[Dict]:
"""Execute a BigQuery SQL query and return results.
Try not to write INSERT statements and use the write method instead.

Expand All @@ -125,9 +135,7 @@ def query(self, query: str, params: dict | None = None) -> List[Dict]:
job_config = bigquery.QueryJobConfig()

if params:
job_config.query_parameters = [
bigquery.ScalarQueryParameter(k, "STRING", v) for k, v in params.items()
]
job_config.query_parameters = params

row_iterator = self.client.query_and_wait(
query, job_config=job_config, retry=retry.Retry(deadline=30)
Expand Down
18 changes: 11 additions & 7 deletions services/processing/flake_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ def process_flake_for_repo_commit(
state__in=["processed", "v2_finished"],
).all()

process_flakes_for_uploads(repo_id, [upload for upload in uploads])

log.info(
"Successfully processed flakes",
extra=dict(repoid=repo_id, commit=commit_id),
)

return {"successful": True}


def process_flakes_for_uploads(repo_id: int, uploads: list[ReportSession]):
curr_flakes = fetch_curr_flakes(repo_id)
new_flakes: dict[str, Flake] = dict()

Expand Down Expand Up @@ -92,13 +103,6 @@ def process_flake_for_repo_commit(
upload.save()
django_transaction.commit()

log.info(
"Successfully processed flakes",
extra=dict(repoid=repo_id, commit=commit_id),
)

return {"successful": True}


def get_test_instances(
upload: ReportSession,
Expand Down
Loading
Loading