Skip to content

Commit

Permalink
Drop python <3.8. Add python 3.10 to CI (#222)
Browse files Browse the repository at this point in the history
Dropped python <3.8. Add python 3.10 to CI.
Changed from deprecated pandas.DataFrame.append to pandas.concat
  • Loading branch information
asnyv authored Aug 30, 2022
1 parent 2230db8 commit 097240f
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 88 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ jobs:
os: [ubuntu-latest]
env:
OS: ${{ matrix.os }}
PYTHON: '3.7'
PYTHON: "3.8"

steps:
- uses: actions/checkout@master
- uses: actions/checkout@master

- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.7
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: 3.8

- name: Install fmu-ensemble and test dependencies
run: |
pip install pip -U
pip install .[tests]
- name: Install fmu-ensemble and test dependencies
run: |
pip install pip -U
pip install .[tests]
- name: Generate coverage report
run: |
pytest tests --disable-warnings --cov=fmu --cov-report=xml
- name: Generate coverage report
run: |
pytest tests --disable-warnings --cov=fmu --cov-report=xml
- name: Upload coverage to Codecov
run: |
bash <(curl -s https://codecov.io/bash)
- name: Upload coverage to Codecov
run: |
bash <(curl -s https://codecov.io/bash)
11 changes: 5 additions & 6 deletions .github/workflows/fmu-ensemble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ on:
- published
schedule:
# Run CI every night and check that tests are working with latest dependencies
- cron: '0 0 * * *'
- cron: "0 0 * * *"

jobs:

fmu-ensemble:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
python-version: ["3.8", "3.9", "3.10"]

steps:
- name: 📖 Checkout commit locally
Expand All @@ -42,7 +41,7 @@ jobs:
pip install .
- name: 📦 Install test dependencies
run:
run: |
pip install ecl2df
pip install .[tests,docs]
Expand Down Expand Up @@ -71,7 +70,7 @@ jobs:
touch build/sphinx/html/.nojekyll
- name: 🚢 Build and deploy Python package
if: github.event_name == 'release' && matrix.python-version == '3.6'
if: github.event_name == 'release' && matrix.python-version == '3.8'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_fmuensemble_token }}
Expand All @@ -81,7 +80,7 @@ jobs:
twine upload dist/*
- name: 📚 Update GitHub pages
if: github.event_name == 'release' && github.repository == 'equinor' && matrix.python-version == '3.6'
if: github.event_name == 'release' && github.repository == 'equinor' && matrix.python-version == '3.8'
run: |
cp -R ./build/sphinx/html ../html
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ In addition:

* Use pytest as testing engine

* Code shall be be Python 2.7.13 + and python 3.4 + compliant
* Code shall be be Python 3.8+ compliant


Use flake8 and/or pylint to check
Expand All @@ -108,4 +108,3 @@ The pylint is rather strict and sometimes exceptions are needed... , but anyway
python -m pylint mycode.py
make lint # for all
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.. image:: https://img.shields.io/lgtm/grade/python/g/equinor/fmu-ensemble.svg?logo=lgtm&logoWidth=18
:target: https://lgtm.com/projects/g/equinor/fmu-ensemble/context:python

.. image:: https://img.shields.io/badge/python-3.6%20|%203.7%20|%203.8%20|%203.9-blue.svg
.. image:: https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10-blue.svg
:target: https://www.python.org

==============================
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
test_suite="tests",
tests_require=test_requirements,
setup_requires=SETUP_REQUIREMENTS,
extras_require=EXTRAS_REQUIRE,
python_requires=">=3.6",
python_requires=">=3.8",
)
6 changes: 1 addition & 5 deletions src/fmu/ensemble/ensembleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,7 @@ def add_ensembles_frompath(
batchname = str(itermatch.group(1))
break
df_row = {"path": path, "real": real, "iter": iterr, "batch": batchname}
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# append deprecated on pandas >= 1.4,
# switch to e.g. pandas.concat when dropping Python 3.6 support
paths_df = paths_df.append(df_row, ignore_index=True)
paths_df = pd.concat([paths_df, pd.DataFrame([df_row])], ignore_index=True)
paths_df.fillna(value="Unknown", inplace=True)
# Initialize ensemble objects for each iter found:
iters = sorted(paths_df["iter"].unique())
Expand Down
80 changes: 32 additions & 48 deletions src/fmu/ensemble/realization.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ def __init__(
"FULLPATH": os.path.join(abspath, "STATUS"),
"BASENAME": "STATUS",
}
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# append deprecated on pandas >= 1.4,
# switch to e.g. pandas.concat when dropping Python 3.6 support
self.files = self.files.append(filerow, ignore_index=True)
self.files = pd.concat(
[self.files, pd.DataFrame([filerow])], ignore_index=True
)
self.load_status()
else:
logger.warning("No STATUS file, %s", abspath)
Expand All @@ -164,11 +162,9 @@ def __init__(
"FULLPATH": os.path.join(abspath, "jobs.json"),
"BASENAME": "jobs.json",
}
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# append deprecated on pandas >= 1.4,
# switch to e.g. pandas.concat when dropping Python 3.6 support
self.files = self.files.append(filerow, ignore_index=True)
self.files = pd.concat(
[self.files, pd.DataFrame([filerow])], ignore_index=True
)

if os.path.exists(os.path.join(abspath, "OK")):
self.load_scalar("OK")
Expand Down Expand Up @@ -323,11 +319,9 @@ def load_scalar(
"FULLPATH": fullpath,
"BASENAME": os.path.split(localpath)[-1],
}
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# append deprecated on pandas >= 1.4,
# switch to e.g. pandas.concat when dropping Python 3.6 support
self.files = self.files.append(filerow, ignore_index=True)
self.files = pd.concat(
[self.files, pd.DataFrame([filerow])], ignore_index=True
)
try:
value = pd.read_csv(
fullpath,
Expand Down Expand Up @@ -403,11 +397,9 @@ class variable keyvaluedata directly, or rerun this function.
"FULLPATH": fullpath,
"BASENAME": os.path.split(localpath)[-1],
}
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# append deprecated on pandas >= 1.4,
# switch to e.g. pandas.concat when dropping Python 3.6 support
self.files = self.files.append(filerow, ignore_index=True)
self.files = pd.concat(
[self.files, pd.DataFrame([filerow])], ignore_index=True
)
try:
keyvalues = pd.read_csv(
fullpath,
Expand Down Expand Up @@ -460,11 +452,9 @@ def load_csv(self, localpath, convert_numeric=True, force_reread=False):
"FULLPATH": fullpath,
"BASENAME": os.path.split(localpath)[-1],
}
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# append deprecated on pandas >= 1.4,
# switch to e.g. pandas.concat when dropping Python 3.6 support
self.files = self.files.append(filerow, ignore_index=True)
self.files = pd.concat(
[self.files, pd.DataFrame([filerow])], ignore_index=True
)
try:
if convert_numeric:
# Trust that Pandas will determine sensible datatypes
Expand Down Expand Up @@ -511,23 +501,17 @@ def load_status(self):
return pd.DataFrame() # will be empty
errorcolumns = ["error" + str(x) for x in range(0, 10)]

with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# error_bad_lines and warn_bad_lines emit a FutureWarning on pandas >= 1.3,
# these two arguments can be replaced with on_bad_lines="skip"
# when dropping Python 3.6 support.
status = pd.read_csv(
statusfile,
sep=r"\s+",
skiprows=1,
header=None,
names=["FORWARD_MODEL", "colon", "STARTTIME", "dots", "ENDTIME"]
+ errorcolumns,
dtype=str,
engine="python",
error_bad_lines=False,
warn_bad_lines=True,
)
status = pd.read_csv(
statusfile,
sep=r"\s+",
skiprows=1,
header=None,
names=["FORWARD_MODEL", "colon", "STARTTIME", "dots", "ENDTIME"]
+ errorcolumns,
dtype=str,
engine="python",
on_bad_lines="skip",
)

# dtype str messes up a little bit, pre-Pandas 0.24.1 gives 'None' as
# a string where data is missing.
Expand Down Expand Up @@ -849,12 +833,12 @@ def find_files(self, paths, metadata=None, metayaml=False):
self.files = self.files[self.files["FULLPATH"] != absmatch]
if metadata:
filerow.update(metadata)
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# append deprecated on pandas >= 1.4,
# switch to e.g. pandas.concat when dropping Python 3.6 support
self.files = self.files.append(filerow, ignore_index=True)
returnedslice = returnedslice.append(filerow, ignore_index=True)
self.files = pd.concat(
[self.files, pd.DataFrame([filerow])], ignore_index=True
)
returnedslice = pd.concat(
[returnedslice, pd.DataFrame([filerow])], ignore_index=True
)
return returnedslice

@property
Expand Down
10 changes: 3 additions & 7 deletions src/fmu/ensemble/virtualrealization.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,9 @@ def get_smry(self, column_keys=None, time_index="monthly"):
# Add the extra datetimes to interpolate at.
smry.set_index("DATE", inplace=True)
smry.index = pd.to_datetime(smry.index)
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
# append deprecated on pandas >= 1.4,
# switch to e.g. pandas.concat when dropping Python 3.6 support
smry = smry.append(
pd.DataFrame(index=pd.to_datetime(time_index_dt)), sort=False
)
smry = pd.concat(
[smry, pd.DataFrame(index=pd.to_datetime(time_index_dt))], sort=False
)
# Drop duplicated dates. It is always the first one which is the
# original.
smry = smry[~smry.index.duplicated(keep="first")]
Expand Down

0 comments on commit 097240f

Please sign in to comment.