-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration to remove arrow_git_revision from context
- Loading branch information
1 parent
150ece1
commit 4e5ff25
Showing
2 changed files
with
337 additions
and
0 deletions.
There are no files selected for viewing
285 changes: 285 additions & 0 deletions
285
conbench/tests/migrations/test_4a5177dc4e44_migrate_contexts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,285 @@ | ||
import os | ||
|
||
from alembic import command | ||
from alembic.config import Config | ||
|
||
from ...db import Session | ||
from ...entities.summary import Summary | ||
|
||
|
||
this_dir = os.path.abspath(os.path.dirname(__file__)) | ||
config_path = os.path.join(this_dir, "../../../alembic.ini") | ||
|
||
|
||
VALID_PAYLOAD_1 = { | ||
"context": { | ||
"arrow_compiler_flags": "-fPIC -arch x86_64 -arch x86_64 -std=c++11 -Qunused-arguments -fcolor-diagnostics -O3 -DNDEBUG", | ||
"arrow_compiler_id": "AppleClang", | ||
"arrow_compiler_version": "11.0.0.11000033", | ||
"arrow_version": "2.0.0", | ||
"arrow_git_revision": "02addad336ba19a654f9c857ede546331be7b631", | ||
"benchmark_language_version": "Python 3.8.5", | ||
"benchmark_language": "Python", | ||
}, | ||
"run": { | ||
"commit": "02addad336ba19a654f9c857ede546331be7b631", | ||
"repository": "https://github.com/apache/arrow", | ||
}, | ||
"machine_info": { | ||
"architecture_name": "x86_64", | ||
"cpu_l1d_cache_bytes": "32768", | ||
"cpu_l1i_cache_bytes": "32768", | ||
"cpu_l2_cache_bytes": "262144", | ||
"cpu_l3_cache_bytes": "4194304", | ||
"cpu_core_count": "2", | ||
"cpu_frequency_max_hz": "3500000000", | ||
"cpu_model_name": "Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz", | ||
"cpu_thread_count": "4", | ||
"kernel_name": "19.6.0", | ||
"memory_bytes": "17179869184", | ||
"name": "diana", | ||
"os_name": "macOS", | ||
"os_version": "10.15.7", | ||
}, | ||
"stats": { | ||
"batch_id": "7b2fdd9f929d47b9960152090d47f8e6", | ||
"run_id": "2a5709d179f349cba69ed242be3e6321", | ||
"run_name": "pull request: 9564", | ||
"data": [ | ||
"0.099094", | ||
"0.037129", | ||
"0.036381", | ||
"0.148896", | ||
"0.008104", | ||
"0.005496", | ||
"0.009871", | ||
"0.006008", | ||
"0.007978", | ||
"0.004733", | ||
], | ||
"times": [ | ||
"0.099094", | ||
"0.037129", | ||
"0.036381", | ||
"0.148896", | ||
"0.008104", | ||
"0.005496", | ||
"0.009871", | ||
"0.006008", | ||
"0.007978", | ||
"0.004733", | ||
], | ||
"unit": "s", | ||
"time_unit": "s", | ||
"iqr": "0.030442", | ||
"iterations": 10, | ||
"max": "0.148896", | ||
"mean": "0.036369", | ||
"median": "0.008988", | ||
"min": "0.004733", | ||
"q1": "0.006500", | ||
"q3": "0.036942", | ||
"stdev": "0.049194", | ||
"timestamp": "2020-11-25T21:02:42.706806+00:00", | ||
}, | ||
"tags": { | ||
"compression": "snappy", | ||
"cpu_count": 2, | ||
"dataset": "nyctaxi_sample", | ||
"file_type": "parquet", | ||
"input_type": "arrow", | ||
"name": "file-write", | ||
}, | ||
} | ||
|
||
|
||
VALID_PAYLOAD_2 = { | ||
"context": { | ||
"arrow_compiler_flags": "-fPIC -arch x86_64 -arch x86_64 -std=c++11 -Qunused-arguments -fcolor-diagnostics -O3 -DNDEBUG", | ||
"arrow_compiler_id": "AppleClang", | ||
"arrow_compiler_version": "11.0.0.11000033", | ||
"arrow_version": "2.0.0", | ||
"benchmark_language_version": "Python 3.8.5", | ||
"benchmark_language": "Python", | ||
}, | ||
"run": { | ||
"commit": "02addad336ba19a654f9c857ede546331be7b631", | ||
"repository": "https://github.com/apache/arrow", | ||
}, | ||
"machine_info": { | ||
"architecture_name": "x86_64", | ||
"cpu_l1d_cache_bytes": "32768", | ||
"cpu_l1i_cache_bytes": "32768", | ||
"cpu_l2_cache_bytes": "262144", | ||
"cpu_l3_cache_bytes": "4194304", | ||
"cpu_core_count": "2", | ||
"cpu_frequency_max_hz": "3500000000", | ||
"cpu_model_name": "Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz", | ||
"cpu_thread_count": "4", | ||
"kernel_name": "19.6.0", | ||
"memory_bytes": "17179869184", | ||
"name": "diana", | ||
"os_name": "macOS", | ||
"os_version": "10.15.7", | ||
}, | ||
"stats": { | ||
"batch_id": "7b2fdd9f929d47b9960152090d47f8e6", | ||
"run_id": "2a5709d179f349cba69ed242be3e6321", | ||
"run_name": "pull request: 9564", | ||
"data": [ | ||
"0.099094", | ||
"0.037129", | ||
"0.036381", | ||
"0.148896", | ||
"0.008104", | ||
"0.005496", | ||
"0.009871", | ||
"0.006008", | ||
"0.007978", | ||
"0.004733", | ||
], | ||
"times": [ | ||
"0.099094", | ||
"0.037129", | ||
"0.036381", | ||
"0.148896", | ||
"0.008104", | ||
"0.005496", | ||
"0.009871", | ||
"0.006008", | ||
"0.007978", | ||
"0.004733", | ||
], | ||
"unit": "s", | ||
"time_unit": "s", | ||
"iqr": "0.030442", | ||
"iterations": 10, | ||
"max": "0.148896", | ||
"mean": "0.036369", | ||
"median": "0.008988", | ||
"min": "0.004733", | ||
"q1": "0.006500", | ||
"q3": "0.036942", | ||
"stdev": "0.049194", | ||
"timestamp": "2020-11-25T21:02:42.706806+00:00", | ||
}, | ||
"tags": { | ||
"compression": "snappy", | ||
"cpu_count": 2, | ||
"dataset": "nyctaxi_sample", | ||
"file_type": "parquet", | ||
"input_type": "arrow", | ||
"name": "file-write", | ||
}, | ||
} | ||
|
||
VALID_PAYLOAD_3 = { | ||
"context": { | ||
"arrow_compiler_flags": "-fPIC -arch x86_64 -arch x86_64 -std=c++11 -Qunused-arguments -fcolor-diagnostics -O3 -DNDEBUG", | ||
"arrow_compiler_id": "AppleClang", | ||
"arrow_compiler_version": "11.0.0.11000033", | ||
"arrow_version": "3.0.0", | ||
"arrow_git_revision": "02addad336ba19a654f9c857ede546331be7b631", | ||
"benchmark_language_version": "Python 3.8.5", | ||
"benchmark_language": "Python", | ||
}, | ||
"run": { | ||
"commit": "02addad336ba19a654f9c857ede546331be7b631", | ||
"repository": "https://github.com/apache/arrow", | ||
}, | ||
"machine_info": { | ||
"architecture_name": "x86_64", | ||
"cpu_l1d_cache_bytes": "32768", | ||
"cpu_l1i_cache_bytes": "32768", | ||
"cpu_l2_cache_bytes": "262144", | ||
"cpu_l3_cache_bytes": "4194304", | ||
"cpu_core_count": "2", | ||
"cpu_frequency_max_hz": "3500000000", | ||
"cpu_model_name": "Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz", | ||
"cpu_thread_count": "4", | ||
"kernel_name": "19.6.0", | ||
"memory_bytes": "17179869184", | ||
"name": "diana", | ||
"os_name": "macOS", | ||
"os_version": "10.15.7", | ||
}, | ||
"stats": { | ||
"batch_id": "7b2fdd9f929d47b9960152090d47f8e6", | ||
"run_id": "2a5709d179f349cba69ed242be3e6321", | ||
"run_name": "pull request: 9564", | ||
"data": [ | ||
"0.099094", | ||
"0.037129", | ||
"0.036381", | ||
"0.148896", | ||
"0.008104", | ||
"0.005496", | ||
"0.009871", | ||
"0.006008", | ||
"0.007978", | ||
"0.004733", | ||
], | ||
"times": [ | ||
"0.099094", | ||
"0.037129", | ||
"0.036381", | ||
"0.148896", | ||
"0.008104", | ||
"0.005496", | ||
"0.009871", | ||
"0.006008", | ||
"0.007978", | ||
"0.004733", | ||
], | ||
"unit": "s", | ||
"time_unit": "s", | ||
"iqr": "0.030442", | ||
"iterations": 10, | ||
"max": "0.148896", | ||
"mean": "0.036369", | ||
"median": "0.008988", | ||
"min": "0.004733", | ||
"q1": "0.006500", | ||
"q3": "0.036942", | ||
"stdev": "0.049194", | ||
"timestamp": "2020-11-25T21:02:42.706806+00:00", | ||
}, | ||
"tags": { | ||
"compression": "snappy", | ||
"cpu_count": 2, | ||
"dataset": "nyctaxi_sample", | ||
"file_type": "parquet", | ||
"input_type": "arrow", | ||
"name": "file-write", | ||
}, | ||
} | ||
|
||
|
||
def test_upgrade(): | ||
summary_1 = Summary.create(VALID_PAYLOAD_1) | ||
summary_2 = Summary.create(VALID_PAYLOAD_2) | ||
summary_3 = Summary.create(VALID_PAYLOAD_3) | ||
|
||
# assert before migration | ||
assert "arrow_git_revision" in summary_1.context.tags | ||
assert "arrow_git_revision" not in summary_2.context.tags | ||
assert "arrow_git_revision" in summary_3.context.tags | ||
assert summary_1.context_id != summary_2.context_id | ||
assert summary_1.context_id != summary_3.context_id | ||
assert summary_2.context_id != summary_3.context_id | ||
|
||
# do migration | ||
alembic_config = Config(config_path) | ||
command.stamp(alembic_config, "b5657b751fb5") | ||
command.upgrade(alembic_config, "4a5177dc4e44") | ||
|
||
Session.refresh(summary_1) | ||
Session.refresh(summary_2) | ||
Session.refresh(summary_3) | ||
|
||
# assert after migration | ||
assert "arrow_git_revision" not in summary_1.context.tags | ||
assert "arrow_git_revision" not in summary_2.context.tags | ||
assert "arrow_git_revision" not in summary_3.context.tags | ||
assert summary_1.context_id == summary_2.context_id | ||
assert summary_1.context_id != summary_3.context_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""migrate contexts | ||
Revision ID: 4a5177dc4e44 | ||
Revises: b5657b751fb5 | ||
Create Date: 2021-04-28 09:29:13.186747 | ||
""" | ||
from alembic import op | ||
from sqlalchemy import MetaData | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "4a5177dc4e44" | ||
down_revision = "b5657b751fb5" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
connection = op.get_bind() | ||
meta = MetaData() | ||
meta.reflect(bind=connection) | ||
context_table = meta.tables["context"] | ||
summary_table = meta.tables["summary"] | ||
|
||
contexts = connection.execute(context_table.select()) | ||
for context in contexts: | ||
if "arrow_git_revision" in context.tags: | ||
new_tags = dict(context.tags) | ||
new_tags.pop("arrow_git_revision") | ||
other = connection.execute( | ||
context_table.select().where( | ||
context_table.c.tags == new_tags, | ||
) | ||
).fetchone() | ||
if other: | ||
connection.execute( | ||
summary_table.update() | ||
.where(summary_table.c.context_id == context.id) | ||
.values(context_id=other.id) | ||
) | ||
context_table.delete().where(context_table.c.id == context.id) | ||
else: | ||
connection.execute( | ||
context_table.update() | ||
.where(context_table.c.id == context.id) | ||
.values(tags=new_tags) | ||
) | ||
|
||
|
||
def downgrade(): | ||
pass |