Skip to content

Commit

Permalink
Fixed bugs related to python 3.10, setup.py avoids use of SQLAlchemy …
Browse files Browse the repository at this point in the history
…>=2.0
  • Loading branch information
ajwdewit committed Mar 1, 2023
1 parent ebf3555 commit 7daa80a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
18 changes: 7 additions & 11 deletions pcse/base/parameter_providers.py
Expand Up @@ -6,18 +6,15 @@
In general these classes are not to be used directly, but are to be subclassed
when creating PCSE simulation units.
"""
import types
import sys
import logging
from datetime import date
import pickle
from collections import Counter, MutableMapping
from collections import Counter
if sys.version_info > (3, 8):
from collections.abc import MutableMapping
else:
from collections import MutableMapping

from ..traitlets import (HasTraits, List, Float, Int, Instance, Dict, Bool, All)
from ..pydispatch import dispatcher
from ..util import Afgen
from .. import exceptions as exc
from ..settings import settings
from .variablekiosk import VariableKiosk


class ParameterProvider(MutableMapping):
Expand All @@ -43,7 +40,6 @@ class ParameterProvider(MutableMapping):
_cropdata = dict()
_timerdata = dict()
_override = dict()
_unique_parameters = list()
_iter = 0 # Counter for iterator
_ncrops_activated = 0 # Counts the number of times `set_crop_type()` has been called.

Expand Down Expand Up @@ -136,7 +132,7 @@ def set_override(self, varname, value, check=True):
if varname in self:
self._override[varname] = value
else:
msg = "Cannot override '%s', parameter does not exist." % varname
msg = "Cannot override '%s', parameter does not already exist." % varname
raise exc.PCSEError(msg)
else:
self._override[varname] = value
Expand Down
4 changes: 4 additions & 0 deletions pcse/fileinput/yaml_cropdataprovider.py
Expand Up @@ -227,6 +227,10 @@ def _get_yaml_files(self, fpath):
raise exc.PCSEError(msg)
crop_names = yaml.safe_load(open(fname))["available_crops"]
crop_yaml_fnames = {crop: os.path.join(fpath, crop + ".yaml") for crop in crop_names}
for crop, fname in crop_yaml_fnames.items():
if not os.path.exists(fname):
msg = f"Cannot find yaml file for crop '{crop}': {fname}"
raise RuntimeError(msg)
return crop_yaml_fnames

def set_active_crop(self, crop_name, variety_name):
Expand Down
5 changes: 4 additions & 1 deletion pcse/util.py
Expand Up @@ -14,7 +14,10 @@
from bisect import bisect_left
import textwrap
import sqlite3
from collections import Iterable
if sys.version_info > (3,8):
from collections.abc import Iterable
else:
from collections import Iterable

from . import exceptions as exc
from .traitlets import TraitType
Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
@@ -1,7 +1,6 @@
SQLAlchemy>=0.8.0
numpy>=1.6.0
PyYAML>=3.11
SQLAlchemy>=1.3,<2.0
PyYAML>=5.1
openpyxl>=3.0
requests>=2.0.0
pandas>=0.20
pandas>=0.25
traitlets-pcse==5.0.0.dev
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -37,7 +37,7 @@ def read(*filenames, **kwargs):
download_url='http://github.com/ajwdewit/pcse/tarball/'+VERSION,
license='EUPL',
author=AUTHOR,
install_requires=['SQLAlchemy>=1.3.0',
install_requires=['SQLAlchemy>=1.3.0, <2.0',
'PyYAML>=5.1',
'openpyxl>=3.0.0',
'requests>=2.0.0',
Expand Down

0 comments on commit 7daa80a

Please sign in to comment.