Skip to content

Commit

Permalink
Testing spawning for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pcubillos committed May 31, 2024
1 parent b120972 commit f82852f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v3
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.17.0

- name: Build wheels
- name: Build wheels and run pytest
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_BUILD: "pip install numpy"
Expand Down
7 changes: 6 additions & 1 deletion mc3/chain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2015-2023 Patricio Cubillos and contributors.
# mc3 is open-source software under the MIT license (see LICENSE).

import platform
import sys
import warnings
import random
Expand All @@ -13,9 +14,13 @@

# Ingnore RuntimeWarnings:
warnings.simplefilter("ignore", RuntimeWarning)
if platform.system() == 'Windows':
multiprocess_context = mp.get_context('spawn')
else:
multiprocess_context = mp.get_context('fork')


class Chain(mp.get_context('fork').Process):
class Chain(multiprocess_context.Process):
"""
Background process. This guy evaluates the model and calculates chisq.
"""
Expand Down
10 changes: 8 additions & 2 deletions mc3/mcmc_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'mcmc',
]

import platform
import time
import ctypes
import multiprocessing as mpr
Expand Down Expand Up @@ -206,11 +207,16 @@ def mcmc(
ncpp[0:nchains % ncpu] += 1

# Launch Chains:
mp_context = mpr.get_context('fork')
if platform.system() == 'Windows':
multiprocess_context = mp.get_context('spawn')
else:
multiprocess_context = mp.get_context('fork')

#mp_context = mpr.get_context('fork')
pipes = []
chains = []
for i in range(ncpu):
p = mp_context.Pipe()
p = multiprocess_context.Pipe()
pipes.append(p[0])
chains.append(
ch.Chain(func, indparams, indparams_dict, p[1], data, uncert,
Expand Down

0 comments on commit f82852f

Please sign in to comment.