[INSTRM-1466] use safe_load() to read a yaml file Created: 20/Nov/21  Updated: 31/Oct/23  Resolved: 31/Oct/23

Status: Done
Project: Instrument control development
Component/s: ics_cobraCharmer
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Normal
Reporter: monodera Assignee: cloomis
Resolution: Done Votes: 0
Labels: EngRun
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I needed to edit a file in ics_cobraCharmer as follows to load a yaml file with PyYAML.

 
— ics_cobraCharmer/python/ics/cobraCharmer/utils/orig.butler.py 2021-11-19 17:01:27.507710048 -1000
+++ ics_cobraCharmer/python/ics/cobraCharmer/utils/butler.py 2021-11-19 17:03:45.186142846 -1000
@@ -230,7 +230,7 @@
"""
yamlPath = configPathForPfi(version=version, rootDir=rootDir)
with open(yamlPath, mode='rt') as yamlFile:

  • config = yaml.load(yamlFile)
    + config = yaml.safe_load(yamlFile)

return [c.strip() for c in config['modules']]
 

I think this is due to an additional requirement for PyYAML 5.1+.  The above modification is the easist one, but there are various ways to specify a loader explicitly in their web site.

 

https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation



 Comments   
Comment by chihyi [ 08/Dec/21 ]

Craig is the person who wrote the butler module. He should know better than me about how to handle this issue.

Comment by monodera [ 30/Oct/23 ]

I made a PR. It would be great if you could have a look.

 

https://github.com/Subaru-PFS/ics_cobraCharmer/pull/14

Comment by monodera [ 31/Oct/23 ]

Merged to master

 

Generated at Sat Feb 10 16:35:47 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.