File "number_extension.py", line 6, in extend_number
for idx in range(num):
RecursionError: maximum recursion depth exceeded while calling a Python object
File "/sw/spack-levante/mambaforge-22.9.0-2-Linux-x86_64-kptncg/lib/python3.10/site-packages/xarray/backends/file_manager.py", line 210, in _acquire_with_cache_info
file = self._cache[self._key]
File "/sw/spack-levante/mambaforge-22.9.0-2-Linux-x86_64-kptncg/lib/python3.10/site-packages/xarray/backends/lru_cache.py", line 56, in __getitem__
File "/sw/spack-levante/mambaforge-22.9.0-2-Linux-x86_64-kptncg/lib/python3.10/site-packages/xarray/backends/netCDF4_.py", line 336, in __init__
self.format = self.ds.data_model
File "/sw/spack-levante/mambaforge-22.9.0-2-Linux-x86_64-kptncg/lib/python3.10/site-packages/xarray/backends/netCDF4_.py", line 398, in ds
return self._acquire()
File "/sw/spack-levante/mambaforge-22.9.0-2-Linux-x86_64-kptncg/lib/python3.10/site-packages/xarray/backends/netCDF4_.py", line 392, in _acquire
with self._manager.acquire_context(needs_lock) as root:
File "/sw/spack-levante/mambaforge-22.9.0-2-Linux-x86_64-kptncg/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "/sw/spack-levante/mambaforge-22.9.0-2-Linux-x86_64-kptncg/lib/python3.10/site-packages/xarray/backends/file_manager.py", line 198, in acquire_context
File "/sw/spack-levante/mambaforge-22.9.0-2-Linux-x86_64-kptncg/lib/python3.10/site-packages/xarray/backends/file_manager.py", line 216, in _acquire_with_cache_info
file = self._opener(*self._args, **kwargs)
File "src/netCDF4/_netCDF4.pyx", line 2353, in netCDF4._netCDF4.Dataset.__init__
File "src/netCDF4/_netCDF4.pyx", line 1963, in netCDF4._netCDF4._ensure_nc_success
FileNotFoundError: [Errno 2] No such file or directory: b'/scrattch/k/k202134/test.nc'
```
<!--
issues in line 9 and 13
-->
:::
::::::::
## Hands-On! (5-10min) {.handson}
1. What are the actual issues in the code from the previous slide based on the error messages?
...
...
@@ -101,19 +91,11 @@ issues in line 9 and 13
## Fixing run-time errors
- Produce sensible debug messages to determine code area with the issue
- Use proper compiler flags for debug output
- Use proper flags for debug output
- Check prerequisites/environment
- Create minimal working example
- Use debugger
## Prevent errors
- Testing!
- Using linters (static code analysis) like [ruff](https://github.com/astral-sh/ruff) for Python
- Even ensure proper formatting with tools like [black](https://github.com/psf/black) for Python