Feature/from netcdf fast #993
Open
Jenkins - WCR / Tests / Declarative: Post Actions
failed
Jan 17, 2025 in 0s
failed: 4, passed: 241
Send us feedback
Details
climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestFuncs.test_load_topography
RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
Stack trace
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
> subprocess.check_output(cmd, stderr=subprocess.STDOUT)
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:116:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../../miniforge3/envs/climada_env/lib/python3.11/subprocess.py:466: in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = (['/var/lib/jenkins/miniforge3/envs/climada_env/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/var/lib/jenkins/climada/data/geoclaw/src'), ...],)
kwargs = {'stderr': -2, 'stdout': -1}
process = <Popen: returncode: 1 args: ['/var/lib/jenkins/miniforge3/envs/climada_env/b...>
stdout = b'Obtaining clawpack from git+https://github.com/clawpack/[email protected]#egg=clawpack\n Updating /var/lib/jenkin...above for output.\n\nnote: This is an issue with the package mentioned above, not pip.\nhint: See above for details.\n'
stderr = None, retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
or pass capture_output=True to capture both.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['/var/lib/jenkins/miniforge3/envs/climada_env/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/var/lib/jenkins/climada/data/geoclaw/src'), '--no-build-isolation', '-e', 'git+https://github.com/clawpack/[email protected]#egg=clawpack']' returned non-zero exit status 1.
../../../../../miniforge3/envs/climada_env/lib/python3.11/subprocess.py:571: CalledProcessError
The above exception was the direct cause of the following exception:
self = <climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestFuncs testMethod=test_load_topography>
@unittest.skipIf(sys.platform.startswith("win"), "does not run on Windows")
def test_load_topography(self):
"""Test _load_topography function"""
# depends on the "clawpack" Python package, so make sure to have a working setup first:
> setup_clawpack()
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/test/test_geoclaw_runner.py:99:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
LOGGER.warning(
"pip install failed with return code %d and stdout:", exc.returncode
)
print(exc.output.decode("utf-8"))
> raise RuntimeError(
"pip install failed with return code %d (see output above)."
" Make sure that a Fortran compiler (e.g. gfortran) is available on "
"your machine before using tc_surge_geoclaw!"
) from exc
E RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:122: RuntimeError
climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestRunner.test_init
ModuleNotFoundError: No module named 'clawpack'
Stack trace
self = <climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestRunner testMethod=test_init>
@unittest.skipIf(sys.platform.startswith("win"), "does not run on Windows")
def test_init(self):
"""Test object initialization"""
# track and centroids are taken from the integration test
track = xr.Dataset(
{
"radius_max_wind": ("time", [15.0, 15, 15, 15, 15, 17, 20, 20]),
"radius_oci": ("time", [202.0, 202, 202, 202, 202, 202, 202, 202]),
"max_sustained_wind": ("time", [105.0, 97, 90, 85, 80, 72, 65, 66]),
"central_pressure": (
"time",
[944.0, 950, 956, 959, 963, 968, 974, 975],
),
"time_step": ("time", np.full((8,), 3, dtype=np.float64)),
},
coords={
"time": np.arange(
"2010-02-05T09:00",
"2010-02-06T09:00",
np.timedelta64(3, "h"),
dtype="datetime64[ns]",
),
"lat": (
"time",
[-26.33, -25.54, -24.79, -24.05, -23.35, -22.7, -22.07, -21.50],
),
"lon": (
"time",
[
-147.27,
-148.0,
-148.51,
-148.95,
-149.41,
-149.85,
-150.27,
-150.56,
],
),
},
attrs={
"sid": "2010029S12177_test",
},
)
centroids = np.array(
[
[-23.8908, -149.8048],
[-23.8628, -149.7431],
[-23.7032, -149.3850],
[-23.7183, -149.2211],
[-23.5781, -149.1434],
[-23.5889, -148.8824],
[-23.2351, -149.9070],
[-23.2049, -149.7927],
]
)
time_offset = track["time"].values[3]
areas = {
"period": (track["time"].values[0], track["time"].values[-1]),
"time_mask": np.ones_like(track["time"].values, dtype=bool),
"time_mask_buffered": np.ones_like(track["time"].values, dtype=bool),
"wind_area": (-151.0, -25.0, -147.0, -22.0),
"landfall_area": (-150.0, -24.0, -148.0, -23.0),
"surge_areas": [
(-150.0, -24.3, -149.0, -23.0),
(-149.0, -24.0, -148.0, -22.6),
],
"centroid_mask": np.ones_like(centroids[:, 0], dtype=bool),
}
topo_path = _test_bathymetry_tif()
with tempfile.TemporaryDirectory() as base_dir:
base_dir = pathlib.Path(base_dir)
> runner = GeoClawRunner(
base_dir, track, time_offset, areas, centroids, topo_path
)
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/test/test_geoclaw_runner.py:219:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/geoclaw_runner.py:205: in __init__
self.write_rundata()
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/geoclaw_runner.py:325: in write_rundata
if not self._read_rundata():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <climada_petals.hazard.tc_surge_geoclaw.geoclaw_runner.GeoClawRunner object at 0x7fa0a442e2d0>
def _read_rundata(self) -> bool:
"""Read rundata object from files, return whether it was succesful
Returns
-------
bool
"""
# pylint: disable=import-outside-toplevel
> import clawpack.amrclaw.data
E ModuleNotFoundError: No module named 'clawpack'
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/geoclaw_runner.py:343: ModuleNotFoundError
climada_petals.hazard.tc_surge_geoclaw.test.test_tc_surge_geoclaw.TestHazardInit.test_init
RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
Stack trace
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
> subprocess.check_output(cmd, stderr=subprocess.STDOUT)
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:116:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../../miniforge3/envs/climada_env/lib/python3.11/subprocess.py:466: in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = (['/var/lib/jenkins/miniforge3/envs/climada_env/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/var/lib/jenkins/climada/data/geoclaw/src'), ...],)
kwargs = {'stderr': -2, 'stdout': -1}
process = <Popen: returncode: 1 args: ['/var/lib/jenkins/miniforge3/envs/climada_env/b...>
stdout = b'Obtaining clawpack from git+https://github.com/clawpack/[email protected]#egg=clawpack\n Updating /var/lib/jenkin...above for output.\n\nnote: This is an issue with the package mentioned above, not pip.\nhint: See above for details.\n'
stderr = None, retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
or pass capture_output=True to capture both.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['/var/lib/jenkins/miniforge3/envs/climada_env/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/var/lib/jenkins/climada/data/geoclaw/src'), '--no-build-isolation', '-e', 'git+https://github.com/clawpack/[email protected]#egg=clawpack']' returned non-zero exit status 1.
../../../../../miniforge3/envs/climada_env/lib/python3.11/subprocess.py:571: CalledProcessError
The above exception was the direct cause of the following exception:
self = <climada_petals.hazard.tc_surge_geoclaw.test.test_tc_surge_geoclaw.TestHazardInit testMethod=test_init>
@unittest.skipIf(sys.platform.startswith("win"), "does not run on Windows")
def test_init(self):
"""Test TCSurgeGeoClaw basic object properties"""
# use dummy track that is too weak to actually produce surge
track = xr.Dataset(
{
"radius_max_wind": ("time", np.full((8,), 20.0)),
"radius_oci": ("time", np.full((8,), 200.0)),
"max_sustained_wind": ("time", np.full((8,), 30.0)),
"central_pressure": ("time", np.full((8,), 990.0)),
"time_step": ("time", np.full((8,), 3, dtype=np.float64)),
"basin": ("time", np.full((8,), "SPW")),
},
coords={
"time": np.arange(
"2010-02-05",
"2010-02-06",
np.timedelta64(3, "h"),
dtype="datetime64[ns]",
),
"lat": ("time", np.linspace(-26.33, -21.5, 8)),
"lon": ("time", np.linspace(-147.27, -150.56, 8)),
},
attrs={
"sid": "2010029S12177_test_dummy",
"name": "Dummy",
"orig_event_flag": True,
"category": 0,
},
)
tracks = TCTracks()
tracks.data = [track, track]
topo_path = _test_bathymetry_tif()
# first run, with automatic centroids
centroids = tracks.generate_centroids(res_deg=0.1, buffer_deg=5.5)
> haz = TCSurgeGeoClaw.from_tc_tracks(tracks, centroids, topo_path)
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/test/test_tc_surge_geoclaw.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/tc_surge_geoclaw.py:253: in from_tc_tracks
setup_clawpack()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
LOGGER.warning(
"pip install failed with return code %d and stdout:", exc.returncode
)
print(exc.output.decode("utf-8"))
> raise RuntimeError(
"pip install failed with return code %d (see output above)."
" Make sure that a Fortran compiler (e.g. gfortran) is available on "
"your machine before using tc_surge_geoclaw!"
) from exc
E RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:122: RuntimeError
climada_petals.test.test_tc_surge_geoclaw.TestGeoclawRun.test_surge_from_track
RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
Stack trace
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
> subprocess.check_output(cmd, stderr=subprocess.STDOUT)
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:116:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../../miniforge3/envs/climada_env/lib/python3.11/subprocess.py:466: in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = (['/var/lib/jenkins/miniforge3/envs/climada_env/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/var/lib/jenkins/climada/data/geoclaw/src'), ...],)
kwargs = {'stderr': -2, 'stdout': -1}
process = <Popen: returncode: 1 args: ['/var/lib/jenkins/miniforge3/envs/climada_env/b...>
stdout = b'Obtaining clawpack from git+https://github.com/clawpack/[email protected]#egg=clawpack\n Updating /var/lib/jenkin...above for output.\n\nnote: This is an issue with the package mentioned above, not pip.\nhint: See above for details.\n'
stderr = None, retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
or pass capture_output=True to capture both.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout is given, and the process takes too long, a TimeoutExpired
exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['/var/lib/jenkins/miniforge3/envs/climada_env/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/var/lib/jenkins/climada/data/geoclaw/src'), '--no-build-isolation', '-e', 'git+https://github.com/clawpack/[email protected]#egg=clawpack']' returned non-zero exit status 1.
../../../../../miniforge3/envs/climada_env/lib/python3.11/subprocess.py:571: CalledProcessError
The above exception was the direct cause of the following exception:
self = <climada_petals.test.test_tc_surge_geoclaw.TestGeoclawRun testMethod=test_surge_from_track>
def test_surge_from_track(self):
"""Test _geoclaw_surge_from_track function (~30 seconds on a notebook)"""
# similar to IBTrACS 2010029S12177 (OLI, 2010) hitting Tubuai
track = xr.Dataset({
'radius_max_wind': ('time', [15., 15, 15, 15, 15, 17, 20, 20]),
'radius_oci': ('time', [202., 202, 202, 202, 202, 202, 202, 202]),
'max_sustained_wind': ('time', [105., 97, 90, 85, 80, 72, 65, 66]),
'central_pressure': ('time', [944., 950, 956, 959, 963, 968, 974, 975]),
'time_step': ('time', np.full((8,), 3, dtype=np.float64)),
}, coords={
'time': np.arange('2010-02-05T09:00', '2010-02-06T09:00',
np.timedelta64(3, 'h'), dtype='datetime64[ns]'),
'lat': ('time', [-26.33, -25.54, -24.79, -24.05,
-23.35, -22.7, -22.07, -21.50]),
'lon': ('time', [-147.27, -148.0, -148.51, -148.95,
-149.41, -149.85, -150.27, -150.56]),
}, attrs={
'sid': '2010029S12177_test',
})
centroids = np.array([
# points along coastline:
[-23.8908, -149.8048], [-23.8628, -149.7431],
[-23.7032, -149.3850], [-23.7183, -149.2211],
[-23.5781, -149.1434], [-23.5889, -148.8824],
# points inland at higher altitude:
[-23.2351, -149.9070], [-23.2049, -149.7927],
])
gauges = [
(-23.9059, -149.6248), # offshore
(-23.8062, -149.2160), # coastal
(-23.2394, -149.8574), # inland
]
> setup_clawpack()
../../../../petals_branches/branches/develop/workspace/climada_petals/test/test_tc_surge_geoclaw.py:96:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
LOGGER.warning(
"pip install failed with return code %d and stdout:", exc.returncode
)
print(exc.output.decode("utf-8"))
> raise RuntimeError(
"pip install failed with return code %d (see output above)."
" Make sure that a Fortran compiler (e.g. gfortran) is available on "
"your machine before using tc_surge_geoclaw!"
) from exc
E RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
../../../../petals_branches/branches/develop/workspace/climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:122: RuntimeError
Loading