Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed May 14, 2024
1 parent 383e9ce commit a0003dd
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 21 deletions.
37 changes: 23 additions & 14 deletions .ci_support/release.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
def get_setup_version_and_pattern(setup_content):
depend_lst, version_lst = [], []
for l in setup_content:
if '==' in l:
lst = l.split('[')[-1].split(']')[0].replace(' ', '').replace('"', '').replace("'", '').split(',')
if "==" in l:
lst = (
l.split("[")[-1]
.split("]")[0]
.replace(" ", "")
.replace('"', "")
.replace("'", "")
.split(",")
)
for dep in lst:
if dep != '\n':
version_lst.append(dep.split('==')[1])
depend_lst.append(dep.split('==')[0])
if dep != "\n":
version_lst.append(dep.split("==")[1])
depend_lst.append(dep.split("==")[0])

version_high_dict = {d: v for d, v in zip(depend_lst, version_lst)}
return version_high_dict
Expand All @@ -16,14 +23,14 @@ def get_env_version(env_content):
read_flag = False
depend_lst, version_lst = [], []
for l in env_content:
if 'dependencies:' in l:
if "dependencies:" in l:
read_flag = True
elif read_flag:
lst = l.replace('-', '').replace(' ', '').replace('\n', '').split("=")
lst = l.replace("-", "").replace(" ", "").replace("\n", "").split("=")
if len(lst) == 2:
depend_lst.append(lst[0])
version_lst.append(lst[1])
return {d:v for d, v in zip(depend_lst, version_lst)}
return {d: v for d, v in zip(depend_lst, version_lst)}


def update_dependencies(setup_content, version_low_dict, version_high_dict):
Expand All @@ -35,27 +42,29 @@ def update_dependencies(setup_content, version_low_dict, version_high_dict):
version_combo_dict[dep] = dep + "==" + ver

setup_content_new = ""
pattern_dict = {d:d + "==" + v for d, v in version_high_dict.items()}
pattern_dict = {d: d + "==" + v for d, v in version_high_dict.items()}
for l in setup_content:
for k, v in pattern_dict.items():
if v in l:
l = l.replace(v, version_combo_dict[k])
setup_content_new +=l
setup_content_new += l
return setup_content_new


if __name__ == "__main__":
with open('pyproject.toml', "r") as f:
with open("pyproject.toml", "r") as f:
setup_content = f.readlines()

with open('environment.yml', "r") as f:
with open("environment.yml", "r") as f:
env_content = f.readlines()

setup_content_new = update_dependencies(
setup_content=setup_content[2:],
version_low_dict=get_env_version(env_content=env_content),
version_high_dict=get_setup_version_and_pattern(setup_content=setup_content[2:]),
version_high_dict=get_setup_version_and_pattern(
setup_content=setup_content[2:]
),
)

with open('pyproject.toml', "w") as f:
with open("pyproject.toml", "w") as f:
f.writelines("".join(setup_content[:2]) + setup_content_new)
4 changes: 4 additions & 0 deletions pympipool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@


__version__ = get_versions()["version"]
__all__ = [
SubprocessExecutor,
ShellExecutor,
]


class Executor:
Expand Down
14 changes: 14 additions & 0 deletions pympipool/shared/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@
from pympipool.shared.executorbase import cancel_items_in_queue
from pympipool.shared.thread import RaisingThread
from pympipool.shared.interface import MpiExecInterface, SrunInterface


__all__ = [
SocketInterface,
interface_bootup,
interface_connect,
interface_send,
interface_shutdown,
interface_receive,
cancel_items_in_queue,
RaisingThread,
MpiExecInterface,
SrunInterface,
]
6 changes: 6 additions & 0 deletions pympipool/shell/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
from pympipool.shell.executor import SubprocessExecutor
from pympipool.shell.interactive import ShellExecutor


__all__ = [
SubprocessExecutor,
ShellExecutor,
]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
setup(
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
)
)
24 changes: 21 additions & 3 deletions tests/benchmark/llh.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,37 @@ def run_static(mean=0.1, sigma=1.1, runs=32):
from pympipool import Executor

run_with_executor(
executor=Executor, mean=0.1, sigma=1.1, runs=32, max_cores=4, backend="mpi", block_allocation=True
executor=Executor,
mean=0.1,
sigma=1.1,
runs=32,
max_cores=4,
backend="mpi",
block_allocation=True,
)
elif run_mode == "pympipool":
from pympipool import Executor

run_with_executor(
executor=Executor, mean=0.1, sigma=1.1, runs=32, max_cores=4, backend="mpi", block_allocation=False
executor=Executor,
mean=0.1,
sigma=1.1,
runs=32,
max_cores=4,
backend="mpi",
block_allocation=False,
)
elif run_mode == "flux":
from pympipool import Executor

run_with_executor(
executor=Executor, mean=0.1, sigma=1.1, runs=32, max_cores=4, backend="flux", block_allocation=True
executor=Executor,
mean=0.1,
sigma=1.1,
runs=32,
max_cores=4,
backend="flux",
block_allocation=True,
)
elif run_mode == "mpi4py":
from mpi4py.futures import MPIPoolExecutor
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmark/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_result(self):
self.assertEqual(min(timing_dict, key=timing_dict.get), "process")
self.assertEqual(max(timing_dict, key=timing_dict.get), "static")
self.assertTrue(timing_dict["process"] < timing_dict["pympipool"])
self.assertTrue(timing_dict["block_allocation"] < timing_dict["process"] * 1.1)
self.assertTrue(timing_dict["block_allocation"] < timing_dict["process"] * 1.1)
self.assertTrue(timing_dict["pympipool"] < timing_dict["process"] * 1.35)
self.assertTrue(timing_dict["process"] < timing_dict["mpi4py"])
self.assertTrue(timing_dict["block_allocation"] < timing_dict["mpi4py"])
Expand Down
10 changes: 8 additions & 2 deletions tests/test_executor_backend_mpi_noblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,17 @@ def test_errors(self):
)
with self.assertRaises(ValueError):
with Executor(
max_cores=1, hostname_localhost=True, backend="mpi", block_allocation=False
max_cores=1,
hostname_localhost=True,
backend="mpi",
block_allocation=False,
) as exe:
exe.submit(resource_dict, resource_dict={})
with self.assertRaises(ValueError):
with Executor(
max_cores=1, hostname_localhost=True, backend="mpi", block_allocation=True
max_cores=1,
hostname_localhost=True,
backend="mpi",
block_allocation=True,
) as exe:
exe.submit(resource_dict, resource_dict={})

0 comments on commit a0003dd

Please sign in to comment.