Skip to content

Commit

Permalink
Merge pull request #942 from Andrew-S-Rosen/yaml
Browse files Browse the repository at this point in the history
Add support for ruamel.yaml 0.18+ by replacing deprecated `.safe_load()` function
  • Loading branch information
rkingsbury committed Apr 16, 2024
2 parents 483962f + ecf2f99 commit 7d6cbaa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
include_package_data=True,
install_requires=[
"setuptools",
"ruamel.yaml<0.18",
"ruamel.yaml>=0.17",
"pydantic>=2.0",
"pydantic-settings>=2.0.3",
"pymongo>=4.2.0",
Expand Down
5 changes: 3 additions & 2 deletions src/maggma/stores/gridfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pydash import get, has
from pymongo import MongoClient, uri_parser
from pymongo.errors import ConfigurationError
from ruamel import yaml
from ruamel.yaml import YAML

from maggma.core import Sort, Store, StoreError
from maggma.stores.mongolike import MongoStore
Expand Down Expand Up @@ -107,7 +107,8 @@ def from_launchpad_file(cls, lp_file, collection_name, **kwargs):
Returns:
"""
with open(lp_file) as f:
lp_creds = yaml.safe_load(f.read())
yaml = YAML(typ="safe", pure=True)
lp_creds = yaml.load(f.read())

db_creds = lp_creds.copy()
db_creds["database"] = db_creds["name"]
Expand Down
5 changes: 3 additions & 2 deletions src/maggma/stores/mongolike.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from itertools import chain, groupby
from pathlib import Path

from ruamel import yaml
from ruamel.yaml import YAML

from maggma.stores.ssh_tunnel import SSHTunnel

Expand Down Expand Up @@ -156,7 +156,8 @@ def from_launchpad_file(cls, lp_file, collection_name, **kwargs):
Returns:
"""
with open(lp_file) as f:
lp_creds = yaml.safe_load(f.read())
yaml = YAML(typ="safe", pure=True)
lp_creds = yaml.load(f.read())

db_creds = lp_creds.copy()
db_creds["database"] = db_creds["name"]
Expand Down

0 comments on commit 7d6cbaa

Please sign in to comment.