Skip to content

Commit

Permalink
Merge pull request #244 from pynbody/pynbody-1.5.1
Browse files Browse the repository at this point in the history
Compatibility fix for pynbody 1.5.1
  • Loading branch information
apontzen authored Dec 3, 2023
2 parents a3ebd96 + 8bf9dc2 commit 77535f4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
'pytest >= 5.0.0',
'webtest >= 2.0',
'pyquery >= 1.3.0',
'pynbody >= 1.5.0',
'pynbody >= 1.5.1',
'yt>=3.4.0',
'PyMySQL>=1.0.2',
]
Expand Down
6 changes: 6 additions & 0 deletions tangos/parallel_tasks/backends/multiprocessing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import multiprocessing
import multiprocessing.resource_tracker
import os
import signal
import sys
Expand Down Expand Up @@ -120,6 +121,11 @@ def launch_functions(functions, args):
if _slave:
raise RuntimeError("Multiprocessing session is already underway")

# the resource tracker must be running before we start any processes,
# otherwise they'll start their own resource trackers and all sorts
# of confusion will ensue
multiprocessing.resource_tracker.ensure_running()

num_procs = len(functions)


Expand Down
6 changes: 3 additions & 3 deletions tangos/parallel_tasks/pynbody_server/transfer_array.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import pynbody
import pynbody.array.shared

from ..message import Message

Expand Down Expand Up @@ -34,9 +34,9 @@ class SharedMemoryArrayInfo(Message):
pass

def _send_array_shared_memory(array: pynbody.array.SimArray, destination: int):
info = pynbody.array._shared_array_deconstruct(array, transfer_ownership=False)
info = pynbody.array.shared._shared_array_deconstruct(array, transfer_ownership=False)
SharedMemoryArrayInfo(info).send(destination)

def _receive_array_shared_memory(source):
info = SharedMemoryArrayInfo.receive(source)
return pynbody.array._shared_array_reconstruct(info.contents)
return pynbody.array.shared._shared_array_reconstruct(info.contents)
16 changes: 16 additions & 0 deletions tests/test_pynbody_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,19 @@ def _test_implict_array_promotion_shared_mem():
def test_implicit_array_promotion_shared_mem():
pt.use("multiprocessing-2")
pt.launch(_test_implict_array_promotion_shared_mem)

def _test_explicit_array_promotion_shared_mem():

f_remote = handler.load_timestep("tiny.000640", mode='server-shared-mem').shared_mem_view

f_remote.dm['pos']
f_remote.gas['pos']
f_remote.star['pos']


f_local = handler.load_timestep("tiny.000640", mode=None)
assert (f_remote['pos'] == f_local['pos']).all()

def test_explicit_array_promotion_shared_mem():
pt.use("multiprocessing-2")
pt.launch(_test_explicit_array_promotion_shared_mem)

0 comments on commit 77535f4

Please # to comment.