Skip to content

Commit

Permalink
Fix config_server for osx (#304)
Browse files Browse the repository at this point in the history
* Changing the `multiprocessing` module to use `fork` explicitly for mac and windows. This shouldn't really be needed. Ideally would also switch out Flask for FastAPI and do a bunch of other improvements.
  • Loading branch information
wtgee authored Aug 30, 2023
1 parent 0cc7240 commit 69efd27
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/pythontest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
exclude:
- os: macos-latest
python-version: '3.8'
os: [ 'ubuntu-latest' ]
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
=========

0.2.42 - 2023-08-30
-------------------

Fixed
^^^^^

* Fixed the config_server on osx.

0.2.41 - 2023-05-17
-------------------

Expand Down
14 changes: 12 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import tempfile
from contextlib import suppress
from pathlib import Path

# Doctest modules
import numpy as np
Expand Down Expand Up @@ -158,11 +159,20 @@ def noheader_fits_file(data_dir):

@pytest.fixture(scope='function')
def cr2_file(data_dir):
cr2_path = os.path.join(data_dir, 'canon.cr2')
cr2_path = Path(data_dir) / 'canon.cr2'

if not os.path.exists(cr2_path):
if cr2_path.exists() is False:
pytest.skip("No CR2 file found, skipping test.")

# The file is fetched in conftest.py but may be a 404-not found text message.
# Try to read as text. If we fail it is because the file is a CR2 (i.e. bytes
# and not text).
try:
_ = cr2_path.read_text()
pytest.skip("CR2 file found but it is not a CR2 file, skipping test.")
except UnicodeDecodeError:
pass

with tempfile.TemporaryDirectory() as tmpdirname:
copy_file = shutil.copy2(cr2_path, tmpdirname)
yield copy_file
Expand Down
7 changes: 7 additions & 0 deletions src/panoptes/utils/config/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
from sys import platform
from multiprocessing import Process

from flask import Flask
Expand All @@ -12,6 +13,12 @@
from panoptes.utils.config.helpers import load_config
from panoptes.utils.config.helpers import save_config

# This seems to be needed. Should switch entire mechanism.
if platform == "darwin" or platform == "win32":
import multiprocessing

multiprocessing.set_start_method('fork')

# Turn off noisy logging for Flask wsgi server.
logging.getLogger('werkzeug').setLevel(logging.WARNING)
logging.getLogger('gevent').setLevel(logging.WARNING)
Expand Down

0 comments on commit 69efd27

Please sign in to comment.