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

Disable mp on weird test #1729

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions oggm/params.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Input/Output paths. Set to ~ to default to home directory

# Where OGGM will write its output
# Can be overridden with the environment variable OGGM_WORKDIR
working_dir =

# Users can specify their own topography file if they want to.
Expand All @@ -23,12 +24,15 @@ climate_file =
rgi_version = 62

# Multiprocessing
# Can be overridden with the environment variable OGGM_USE_MULTIPROCESSING
use_multiprocessing = False
# Number of processors to use (-1 = all available)
# Can be overridden with the environment variable SLURM_JOB_CPUS_PER_NODE
mp_processes = -1
# To avoid race issues when using GDAL, it might be necessary to set this
# to "true". It makes the initialisation of the pool slower, which is
# why it is false per default
# Can be overridden with the environment variable OGGM_USE_MP_SPAWN
use_mp_spawn = False

# Continue on error?
Expand Down
14 changes: 9 additions & 5 deletions oggm/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import xarray as xr
from numpy.testing import assert_array_equal, assert_allclose

salem = pytest.importorskip('salem')
gpd = pytest.importorskip('geopandas')

import oggm
from oggm import utils, workflow, tasks, global_tasks
from oggm.utils import _downloads
Expand All @@ -30,6 +27,14 @@
DownloadVerificationFailedException)
from oggm.core import flowline

salem = pytest.importorskip('salem')
gpd = pytest.importorskip('geopandas')

# Python 3.12+ gives a deprecation warning if TarFile.extraction_filter is None.
# https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter
if hasattr(tarfile, "fully_trusted_filter"):
tarfile.TarFile.extraction_filter = staticmethod(tarfile.fully_trusted_filter) # type: ignore


pytestmark = pytest.mark.test_env("utils")

Expand Down Expand Up @@ -1675,7 +1680,7 @@ def test_start_from_prepro(self):
test_rgidf=rgidf, test_intersects_file=inter,
start_level=1, start_base_url=base_url,
mb_calibration_strategy='melt_temp',
disable_mp=self.on_mac,
disable_mp=True, # Until CRU is fixed we just disable mp
logging_level='INFO', max_level=5, elev_bands=True,
override_params={'geodetic_mb_period': ref_period,
'baseline_climate': 'CRU',
Expand Down Expand Up @@ -2536,7 +2541,6 @@ def test_file_extractor(self):

# writing file to a tar.gz
tmp_comp = os.path.join(cfg.PATHS['working_dir'], 'f.nc.tar.gz')
import tarfile
with tarfile.open(tmp_comp, 'w:gz') as zip:
zip.add(tmp_file, arcname='f.nc')
of = utils.file_extractor(tmp_comp)
Expand Down
5 changes: 5 additions & 0 deletions oggm/utils/_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
HttpDownloadError, HttpContentTooShortError,
InvalidDEMError, FTPSDownloadError)

# Python 3.12+ gives a deprecation warning if TarFile.extraction_filter is None.
# https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter
if hasattr(tarfile, "fully_trusted_filter"):
tarfile.TarFile.extraction_filter = staticmethod(tarfile.fully_trusted_filter) # type: ignore

# Module logger
logger = logging.getLogger('.'.join(__name__.split('.')[:-1]))

Expand Down
4 changes: 4 additions & 0 deletions oggm/utils/_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
except ImportError:
pass

# Python 3.12+ gives a deprecation warning if TarFile.extraction_filter is None.
# https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter
if hasattr(tarfile, "fully_trusted_filter"):
tarfile.TarFile.extraction_filter = staticmethod(tarfile.fully_trusted_filter) # type: ignores

# Locals
from oggm import __version__
Expand Down