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

Initial Job Sizing Infrastructure #488

Merged
merged 19 commits into from
Jan 30, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removed unnecessary unit tests for gempyor.batch
Removed old (already commented out) unit tests for `JobResources` and
`JobSize`.
TimothyWillard committed Jan 29, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 41accb08db61ea477a63126b12c13982ca10be55
58 changes: 0 additions & 58 deletions flepimop/gempyor_pkg/tests/batch/test_job_resources_class.py
Original file line number Diff line number Diff line change
@@ -39,61 +39,3 @@ def test_instance_attributes(nodes: int, cpus: int, memory: int) -> None:
assert job_resources.total_cpus >= cpus
assert job_resources.total_memory >= memory
assert job_resources.total_resources() == (nodes, nodes * cpus, nodes * memory)


# @pytest.mark.parametrize("nodes", (1, 2, 4, 8))
# @pytest.mark.parametrize("cpus", (1, 2, 4, 8))
# @pytest.mark.parametrize("memory", (1024, 2 * 1024, 4 * 1024, 8 * 1024))
# @pytest.mark.parametrize(
# "batch_system", (BatchSystem.AWS, BatchSystem.LOCAL, BatchSystem.SLURM, None)
# )
# def test_formatting(
# nodes: int, cpus: int, memory: int, batch_system: BatchSystem | None
# ) -> None:
# job_resources = JobResources(nodes=nodes, cpus=cpus, memory=memory)

# formatted_nodes = job_resources.format_nodes(batch_system)
# assert isinstance(formatted_nodes, str)
# assert str(nodes) in formatted_nodes

# formatted_cpus = job_resources.format_cpus(batch_system)
# assert isinstance(formatted_cpus, str)
# assert str(cpus) in formatted_cpus

# formatted_memory = job_resources.format_memory(batch_system)
# assert isinstance(formatted_memory, str)
# assert str(memory) in formatted_memory


# @pytest.mark.parametrize("jobs", (1, 4, 16, 32))
# @pytest.mark.parametrize("simulations", (250, 4 * 250, 16 * 250, 32 * 250))
# @pytest.mark.parametrize("blocks", (1, 4, 16, 32))
# @pytest.mark.parametrize("inference_method", ("emcee", None))
# def test_from_presets_for_select_inputs(
# jobs: int, simulations: int, blocks: int, inference_method: Literal["emcee"] | None
# ) -> None:
# job_size = JobSize(jobs=jobs, simulations=simulations, blocks=blocks)
# job_resources = JobResources.from_presets(job_size, inference_method)
# if inference_method == "emcee":
# assert job_resources.nodes == 1
# assert job_resources.cpus % 2 == 0
# assert job_resources.memory % (2 * 1024) == 0
# else:
# assert job_resources.cpus == 2
# assert job_resources.memory == 2 * 1024


# @pytest.mark.parametrize("inference_method", ("emcee", None))
# @pytest.mark.parametrize("nodes", (1, 2, 4, 8))
# @pytest.mark.parametrize("cpus", (1, 2, 4, 8))
# @pytest.mark.parametrize("memory", (1024, 2 * 1024, 4 * 1024, 8 * 1024))
# def test_from_presets_overrides(
# inference_method: Literal["emcee"] | None, nodes: int, cpus: int, memory: int
# ) -> None:
# job_size = JobSize(jobs=1, simulations=1, blocks=1)
# job_resources = JobResources.from_presets(
# job_size, inference_method, nodes=nodes, cpus=cpus, memory=memory
# )
# assert job_resources.nodes == nodes
# assert job_resources.cpus == cpus
# assert job_resources.memory == memory
43 changes: 0 additions & 43 deletions flepimop/gempyor_pkg/tests/batch/test_job_size_class.py
Original file line number Diff line number Diff line change
@@ -30,46 +30,3 @@ def test_less_than_one_value_error(
),
):
JobSize(**kwargs)


# def generate_from_jobs_simulations_blocks(
# *args: int | None,
# ) -> Generator[tuple[int | None, ...], None, None]:
# for combo in product(args, repeat=3):
# yield combo


# @pytest.mark.parametrize("combo", generate_from_jobs_simulations_blocks(1, 5, 10))
# def test_from_jobs_simulations_blocks_output(combo: tuple[int, ...]) -> None:
# jobs, simulations, blocks = combo
# for inference_method in (None, ""):
# for batch_system in (None, BatchSystem.AWS, BatchSystem.LOCAL, BatchSystem.SLURM):
# job_size = JobSize.from_jobs_simulations_blocks(
# jobs, simulations, blocks, inference_method, batch_system
# )
# assert job_size.jobs >= 1
# assert job_size.simulations >= simulations
# assert job_size.blocks >= 1


# @pytest.mark.parametrize(
# ("jobs", "simulations", "blocks", "inference_method", "batch_system", "expected"),
# (
# (4, 32, 8, None, None, JobSize(jobs=4, simulations=32, blocks=8)),
# (4, 32, 8, None, BatchSystem.LOCAL, JobSize(jobs=1, simulations=10, blocks=1)),
# (4, 4, 1, "emcee", BatchSystem.LOCAL, JobSize(jobs=1, simulations=4, blocks=1)),
# (4, 16, 8, "emcee", None, JobSize(jobs=4, simulations=8 * 16, blocks=1)),
# ),
# )
# def test_from_jobs_simulations_blocks_exact_results_for_select_inputs(
# jobs: int | None,
# simulations: int | None,
# blocks: int | None,
# inference_method: Literal["emcee"] | None,
# batch_system: BatchSystem,
# expected: JobSize,
# ) -> None:
# job_size = JobSize.from_jobs_simulations_blocks(
# jobs, simulations, blocks, inference_method, batch_system
# )
# assert job_size == expected