mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 11:33:42 +02:00
[ci] Re-enable fail on warning for pytest pipeline. (#265)
* [ci] Re-enable fail on warning for pytest pipeline. * [Fix] Use sqlite3 context managers in pandas module. * [Fix] Add closing context.
This commit is contained in:
parent
8183ee2ef4
commit
d6e6a435a8
2 changed files with 6 additions and 7 deletions
2
.github/workflows/pytest.yml
vendored
2
.github/workflows/pytest.yml
vendored
|
@ -43,4 +43,4 @@ jobs:
|
||||||
uv pip freeze --system
|
uv pip freeze --system
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pytest --cov=pyerrors -vv
|
run: pytest --cov=pyerrors -vv -Werror
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import warnings
|
import warnings
|
||||||
import gzip
|
import gzip
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
from contextlib import closing
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from ..obs import Obs
|
from ..obs import Obs
|
||||||
from ..correlators import Corr
|
from ..correlators import Corr
|
||||||
|
@ -29,9 +30,8 @@ def to_sql(df, table_name, db, if_exists='fail', gz=True, **kwargs):
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
se_df = _serialize_df(df, gz=gz)
|
se_df = _serialize_df(df, gz=gz)
|
||||||
con = sqlite3.connect(db)
|
with closing(sqlite3.connect(db)) as con:
|
||||||
se_df.to_sql(table_name, con, if_exists=if_exists, index=False, **kwargs)
|
se_df.to_sql(table_name, con=con, if_exists=if_exists, index=False, **kwargs)
|
||||||
con.close()
|
|
||||||
|
|
||||||
|
|
||||||
def read_sql(sql, db, auto_gamma=False, **kwargs):
|
def read_sql(sql, db, auto_gamma=False, **kwargs):
|
||||||
|
@ -52,9 +52,8 @@ def read_sql(sql, db, auto_gamma=False, **kwargs):
|
||||||
data : pandas.DataFrame
|
data : pandas.DataFrame
|
||||||
Dataframe with the content of the sqlite database.
|
Dataframe with the content of the sqlite database.
|
||||||
"""
|
"""
|
||||||
con = sqlite3.connect(db)
|
with closing(sqlite3.connect(db)) as con:
|
||||||
extract_df = pd.read_sql(sql, con, **kwargs)
|
extract_df = pd.read_sql(sql, con=con, **kwargs)
|
||||||
con.close()
|
|
||||||
return _deserialize_df(extract_df, auto_gamma=auto_gamma)
|
return _deserialize_df(extract_df, auto_gamma=auto_gamma)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue