Add MongoDB migration CLI for Parquet dataset #14
+449
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
src/api.pyso the CLI matches the fetcher’s normalizationTesting
from click.testing import CliRunner
from datetime import datetime, timezone
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import patch
import mongomock
from scripts.migrate_mongo_to_parquet import main as migrate
from src import api
client = mongomock.MongoClient()
db = client['fmriprep_stats']
now = datetime(2024, 1, 15, 12, 0, tzinfo=timezone.utc)
for idx, event in enumerate(api.ISSUES, 1):
coll = db[event]
for i in range(3):
coll.insert_one(
{
"_id": f"mongo-{event}-{i}",
"id": f"{event}-{i}",
"dateCreated": now.isoformat(),
"tags": [
{"key": "environment", "value": "prod"},
{"key": "platform", "value": "linux"},
],
}
)
runner = CliRunner()
with TemporaryDirectory() as tmpdir:
dataset_root = Path(tmpdir) / "dataset"
PY
https://chatgpt.com/codex/tasks/task_e_68db981765988330bb8574b8d28c19ce