Skip to content

Commit

Permalink
moved workspace and its tests to gymlib
Browse files Browse the repository at this point in the history
  • Loading branch information
wangpatrick57 committed Dec 30, 2024
1 parent 7c05fa6 commit 257b497
Show file tree
Hide file tree
Showing 28 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion benchmark/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click
from gymlib.workspace import DBGymWorkspace

from benchmark.job.cli import job_group
from benchmark.tpch.cli import tpch_group
from util.workspace import DBGymWorkspace


@click.group(name="benchmark")
Expand Down
6 changes: 3 additions & 3 deletions benchmark/job/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
from typing import Optional

import click
from gymlib import (
from gymlib.shell import subprocess_run
from gymlib.symlinks_paths import (
get_tables_dirname,
get_workload_dirname,
get_workload_suffix,
name_to_linkname,
)
from gymlib.shell import subprocess_run
from gymlib.workspace import DBGymWorkspace, fully_resolve_path

from benchmark.constants import DEFAULT_SCALE_FACTOR
from util.workspace import DBGymWorkspace, fully_resolve_path

JOB_TABLES_URL = "https://event.cwi.nl/da/job/imdb.tgz"
JOB_QUERIES_URL = "https://event.cwi.nl/da/job/job.tgz"
Expand Down
4 changes: 2 additions & 2 deletions benchmark/job/load_info.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pathlib import Path
from typing import Optional

from gymlib import get_tables_symlink_path
from gymlib.symlinks_paths import get_tables_symlink_path
from gymlib.workspace import DBGymWorkspace, fully_resolve_path

from benchmark.constants import DEFAULT_SCALE_FACTOR
from dbms.load_info_base_class import LoadInfoBaseClass
from util.workspace import DBGymWorkspace, fully_resolve_path

JOB_SCHEMA_FNAME = "job_schema.sql"

Expand Down
12 changes: 6 additions & 6 deletions benchmark/tests/integtest_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
import unittest
from pathlib import Path

from gymlib import (
from gymlib.symlinks_paths import (
get_tables_symlink_path,
get_workload_suffix,
get_workload_symlink_path,
)
from gymlib.workspace import (
DBGymWorkspace,
fully_resolve_path,
get_workspace_path_from_config,
)

# It's ok to import private functions from the benchmark module because this is an integration test.
from benchmark.constants import DEFAULT_SCALE_FACTOR
from benchmark.job.cli import _job_tables, _job_workload
from benchmark.tpch.cli import _tpch_tables, _tpch_workload
from benchmark.tpch.constants import DEFAULT_TPCH_SEED
from util.workspace import (
DBGymWorkspace,
fully_resolve_path,
get_workspace_path_from_config,
)


class BenchmarkTests(unittest.TestCase):
Expand Down
6 changes: 3 additions & 3 deletions benchmark/tpch/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging

import click
from gymlib import (
from gymlib.shell import subprocess_run
from gymlib.symlinks_paths import (
get_scale_factor_string,
get_tables_dirname,
get_tables_symlink_path,
Expand All @@ -10,11 +11,10 @@
linkname_to_name,
name_to_linkname,
)
from gymlib.shell import subprocess_run
from gymlib.workspace import DBGymWorkspace, fully_resolve_path, is_fully_resolved

from benchmark.constants import DEFAULT_SCALE_FACTOR
from benchmark.tpch.constants import DEFAULT_TPCH_SEED, NUM_TPCH_QUERIES
from util.workspace import DBGymWorkspace, fully_resolve_path, is_fully_resolved

TPCH_KIT_DIRNAME = "tpch-kit"

Expand Down
4 changes: 2 additions & 2 deletions benchmark/tpch/load_info.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from pathlib import Path
from typing import Optional

from gymlib import get_tables_symlink_path
from gymlib.symlinks_paths import get_tables_symlink_path
from gymlib.workspace import DBGymWorkspace, fully_resolve_path

from dbms.load_info_base_class import LoadInfoBaseClass
from util.workspace import DBGymWorkspace, fully_resolve_path

TPCH_SCHEMA_FNAME = "tpch_schema.sql"
TPCH_CONSTRAINTS_FNAME = "tpch_constraints.sql"
Expand Down
2 changes: 1 addition & 1 deletion dbms/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import click
from gymlib.workspace import DBGymWorkspace

from dbms.postgres.cli import postgres_group
from util.workspace import DBGymWorkspace


@click.group(name="dbms")
Expand Down
18 changes: 9 additions & 9 deletions dbms/postgres/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
import psutil
import psycopg
import sqlalchemy
from gymlib import (
from gymlib.shell import subprocess_run
from gymlib.symlinks_paths import (
get_dbdata_tgz_symlink_path,
get_pgbin_symlink_path,
get_repo_symlink_path,
linkname_to_name,
)
from gymlib.shell import subprocess_run
from sqlalchemy import create_engine, text

from benchmark.constants import DEFAULT_SCALE_FACTOR
from benchmark.job.load_info import JobLoadInfo
from benchmark.tpch.load_info import TpchLoadInfo
from dbms.load_info_base_class import LoadInfoBaseClass
from util.workspace import (
from gymlib.workspace import (
WORKSPACE_PATH_PLACEHOLDER,
DBGymWorkspace,
fully_resolve_path,
get_tmp_path_from_workspace_path,
is_fully_resolved,
is_ssd,
)
from sqlalchemy import create_engine, text

from benchmark.constants import DEFAULT_SCALE_FACTOR
from benchmark.job.load_info import JobLoadInfo
from benchmark.tpch.load_info import TpchLoadInfo
from dbms.load_info_base_class import LoadInfoBaseClass

DBGYM_POSTGRES_USER = "dbgym_user"
DBGYM_POSTGRES_PASS = "dbgym_pass"
Expand Down
10 changes: 5 additions & 5 deletions dbms/tests/integtest_dbms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import unittest
from pathlib import Path

from gymlib import get_dbdata_tgz_symlink_path, get_repo_symlink_path

from benchmark.tpch.cli import _tpch_tables
from dbms.postgres.cli import _postgres_build, _postgres_dbdata
from util.workspace import (
from gymlib.symlinks_paths import get_dbdata_tgz_symlink_path, get_repo_symlink_path
from gymlib.workspace import (
DBGymWorkspace,
fully_resolve_path,
get_workspace_path_from_config,
)

from benchmark.tpch.cli import _tpch_tables
from dbms.postgres.cli import _postgres_build, _postgres_dbdata


class DBMSTests(unittest.TestCase):
DBGYM_CONFIG_PATH = Path("dbms/tests/dbms_integtest_dbgym_config.yaml")
Expand Down
2 changes: 1 addition & 1 deletion env/pg_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import psutil
import psycopg
import yaml
from gymlib.workspace import DBGymWorkspace, parent_path_of_path
from plumbum import local
from psycopg.errors import ProgramLimitExceeded, QueryCanceled

Expand All @@ -27,7 +28,6 @@
SHARED_PRELOAD_LIBRARIES,
get_kv_connstr,
)
from util.workspace import DBGymWorkspace, parent_path_of_path

CONNECT_TIMEOUT = 300

Expand Down
3 changes: 2 additions & 1 deletion env/replay.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from collections import defaultdict
from pathlib import Path

from gymlib.workspace import DBGymWorkspace

from env.pg_conn import PostgresConn
from env.tuning_artifacts import TuningArtifactsReader
from env.workload import Workload
from util.pg import DEFAULT_POSTGRES_PORT
from util.workspace import DBGymWorkspace


def replay(
Expand Down
10 changes: 5 additions & 5 deletions env/tests/gymlib_integtest_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
from typing import Optional

# TODO: remove symlinks_paths from the import
from gymlib import (
from gymlib.symlinks_paths import (
get_dbdata_tgz_symlink_path,
get_pgbin_symlink_path,
get_workload_suffix,
get_workload_symlink_path,
)

from benchmark.tpch.constants import DEFAULT_TPCH_SEED
from env.tuning_artifacts import TuningMetadata
from util.workspace import (
from gymlib.workspace import (
DBGymWorkspace,
fully_resolve_path,
get_tmp_path_from_workspace_path,
get_workspace_path_from_config,
)

from benchmark.tpch.constants import DEFAULT_TPCH_SEED
from env.tuning_artifacts import TuningMetadata


class GymlibIntegtestManager:
"""
Expand Down
2 changes: 1 addition & 1 deletion env/tests/integtest_pg_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import unittest

import psycopg
from gymlib.workspace import DBGymWorkspace

from env.pg_conn import PostgresConn
from env.tests.gymlib_integtest_util import GymlibIntegtestManager
Expand All @@ -10,7 +11,6 @@
get_is_postgres_running,
get_running_postgres_ports,
)
from util.workspace import DBGymWorkspace


class PostgresConnTests(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion env/tests/integtest_replay.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import unittest

from gymlib.workspace import DBGymWorkspace

from benchmark.tpch.constants import DEFAULT_TPCH_SEED
from env.replay import replay
from env.tests.gymlib_integtest_util import GymlibIntegtestManager
Expand All @@ -10,7 +12,6 @@
SysKnobsDelta,
TuningArtifactsWriter,
)
from util.workspace import DBGymWorkspace


class ReplayTests(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion env/tests/integtest_tuning_artifacts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import unittest

from gymlib.workspace import DBGymWorkspace

from env.tests.gymlib_integtest_util import GymlibIntegtestManager
from env.tuning_artifacts import (
DBMSConfigDelta,
Expand All @@ -9,7 +11,6 @@
TuningArtifactsReader,
TuningArtifactsWriter,
)
from util.workspace import DBGymWorkspace


class PostgresConnTests(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion env/tests/integtest_workload.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import unittest

from gymlib.workspace import DBGymWorkspace

from benchmark.tpch.constants import DEFAULT_TPCH_SEED, NUM_TPCH_QUERIES
from env.tests.gymlib_integtest_util import GymlibIntegtestManager
from env.workload import Workload
from util.workspace import DBGymWorkspace


class WorkloadTests(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion env/tuning_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path
from typing import Any, NewType

from util.workspace import DBGymWorkspace, is_fully_resolved
from gymlib.workspace import DBGymWorkspace, is_fully_resolved

# PostgresConn doesn't use these types because PostgresConn is used internally by tuning agents
# while these types are only used in the interface between the orchestrator and the tuning agents.
Expand Down
2 changes: 1 addition & 1 deletion env/workload.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

from util.workspace import DBGymWorkspace, is_fully_resolved
from gymlib.workspace import DBGymWorkspace, is_fully_resolved


class Workload:
Expand Down
Empty file added gymlib_package/__init__.py
Empty file.
6 changes: 1 addition & 5 deletions gymlib_package/gymlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
# Everything at the "core" of gymlib will be imported directly (e.g. `from .[module] import *`).
# Everything not as important will be only be imported as a module (e.g. `from . import [module]`).
from . import shell
from .magic import *
from .symlinks_paths import *
from . import magic, shell, symlinks_paths, workspace
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest
from pathlib import Path

from util.tests.filesystem_unittest_util import (
from gymlib.tests.filesystem_unittest_util import (
FilesystemStructure,
create_structure,
verify_structure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from pathlib import Path
from typing import Optional

from util.tests.filesystem_unittest_util import (
from gymlib.tests.filesystem_unittest_util import (
FilesystemStructure,
create_structure,
make_workspace_structure,
verify_structure,
)
from util.workspace import DBGymWorkspace
from gymlib.workspace import DBGymWorkspace


class WorkspaceTests(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion util/workspace.py → gymlib_package/gymlib/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import IO, Any, Optional

import yaml
from gymlib import is_linkname, name_to_linkname
from gymlib.symlinks_paths import is_linkname, name_to_linkname

WORKSPACE_PATH_PLACEHOLDER = Path("[workspace]")

Expand Down
3 changes: 1 addition & 2 deletions manage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from pathlib import Path

import click

from util.workspace import (
from gymlib.workspace import (
DBGymWorkspace,
get_runs_path_from_workspace_path,
get_symlinks_path_from_workspace_path,
Expand Down
5 changes: 3 additions & 2 deletions manage/tests/unittest_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import unittest
from pathlib import Path

from manage.cli import MockDBGymWorkspace, clean_workspace
from util.tests.filesystem_unittest_util import (
from gymlib.tests.filesystem_unittest_util import (
FilesystemStructure,
create_structure,
make_workspace_structure,
verify_structure,
)

from manage.cli import MockDBGymWorkspace, clean_workspace

# This is here instead of on `if __name__ == "__main__"` because we often run individual tests, which
# does not go through the `if __name__ == "__main__"` codepath.
# Make it DEBUG to see logs from verify_structure(). Make it CRITICAL to not see any logs.
Expand Down
2 changes: 1 addition & 1 deletion task.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import click
from gymlib.workspace import make_standard_dbgym_workspace

from benchmark.cli import benchmark_group
from dbms.cli import dbms_group
from manage.cli import manage_group
from util.workspace import make_standard_dbgym_workspace

# TODO(phw2): Save commit, git diff, and run command.
# TODO(phw2): Remove write permissions on old run_*/ dirs to enforce that they are immutable.
Expand Down

0 comments on commit 257b497

Please sign in to comment.