Skip to content

Commit a98c1c6

Browse files
authored
chore: 'delete' python alias/upstream cron (#4965)
(delete is in scare quotes because I actually just moved it to the frontend emulator)
1 parent f4dac8b commit a98c1c6

11 files changed

Lines changed: 7 additions & 1060 deletions

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ worker-tests:
2525
importer-tests:
2626
cd gcp/workers/importer && ./run_tests.sh
2727

28-
alias-tests:
29-
cd gcp/workers/alias && ./run_tests.sh
30-
3128
recoverer-tests:
3229
cd gcp/workers/recoverer && ./run_tests.sh
3330

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python3
21
# Copyright 2023 Google LLC
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +20,6 @@
2120

2221
import osv
2322
from osv import gcs, pubsub
24-
import osv.logs
2523

2624
ALIAS_GROUP_VULN_LIMIT = 32
2725
VULN_ALIASES_LIMIT = 5
@@ -139,7 +137,7 @@ def transaction():
139137
vuln_proto.SerializeToString(deterministic=True), type='gcs_retry')
140138

141139

142-
def main():
140+
def run():
143141
"""Updates all alias groups in the datastore by re-computing existing
144142
AliasGroups and creating new AliasGroups for un-computed bugs."""
145143

@@ -203,10 +201,3 @@ def main():
203201
# For each updated vulnerability, update them in Datastore & GCS
204202
for vuln_id, alias_group in changed_vulns.items():
205203
_update_vuln_with_group(vuln_id, alias_group)
206-
207-
208-
if __name__ == '__main__':
209-
_ndb_client = ndb.Client()
210-
osv.logs.setup_gcp_logging('alias')
211-
with _ndb_client.context():
212-
main()
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from google.cloud import ndb
2424

2525
import osv
26-
import osv.logs
2726
from osv import gcs, pubsub
2827

2928

@@ -196,7 +195,7 @@ def set_default(obj):
196195
target_upstream_group.put()
197196

198197

199-
def main():
198+
def run():
200199
"""Updates all upstream groups in the datastore by re-computing existing
201200
UpstreamGroups and creating new UpstreamGroups for un-computed bugs."""
202201

@@ -242,10 +241,3 @@ def main():
242241
# Recompute the upstream hierarchies
243242
compute_upstream_hierarchy(group, upstream_groups)
244243
logging.info('Upstream hierarchy updated for bug: %s', group.db_id)
245-
246-
247-
if __name__ == '__main__':
248-
_ndb_client = ndb.Client()
249-
osv.logs.setup_gcp_logging('upstream')
250-
with _ndb_client.context():
251-
main()

gcp/website/frontend_emulator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
from google.cloud import ndb
2222
import osv
2323
import datetime
24-
from gcp.workers.alias import upstream_computation, alias_computation
24+
25+
import emulator_aliases
26+
import emulator_upstream
2527

2628
if __name__ == '__main__':
2729
# The datastore emulator needs to be started before main is imported
@@ -115,8 +117,8 @@ def _load_dir(emulator, dir_path: str):
115117
bug.put()
116118

117119
# Compute upstream/alias groups based on loaded bugs.
118-
upstream_computation.main()
119-
alias_computation.main()
120+
emulator_aliases.run()
121+
emulator_upstream.run()
120122

121123
for b in osv.Bug.query():
122124
b.put()

gcp/workers/alias/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)