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

Add progress bar for long running migrations #1202

Merged
merged 2 commits into from
Dec 4, 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
11 changes: 9 additions & 2 deletions core/migrations/arangodb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import logging
import time

import tqdm

from core.database_arango import ASYNC_JOB_WAIT_TIME, ArangoDatabase
from core.migrations import migration

Expand Down Expand Up @@ -51,8 +54,12 @@ def migration_0():
def migration_1():
from core.schemas import observable

for obs in observable.Observable.list():
obs.save()
total_observables = observable.Observable.count()
logging.info(f"Migrating {total_observables} observables. This may take a while...")
with tqdm.tqdm(total=total_observables, desc="Migrating observables") as pbar:
for obs in observable.Observable.list():
obs.save()
pbar.update(1)


ArangoMigrationManager.register_migration(migration_0)
Expand Down
23 changes: 22 additions & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ yara-python = "^4.5.0"
idstools = "^0.6.5"
aenum = "^3.1.15"
boto3 = { version = "^1.35.22", optional = true }
tqdm = "^4.67.1"

[tool.poetry.group.dev.dependencies]
pylint = "^2.16.1"
Expand Down
Loading