Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using YAML tags and Python types with PyYAML. #118

Closed
grabear opened this issue Nov 9, 2017 · 2 comments
Closed

Using YAML tags and Python types with PyYAML. #118

grabear opened this issue Nov 9, 2017 · 2 comments

Comments

@grabear
Copy link
Member

grabear commented Nov 9, 2017

(Note: This is mostly just a forum for discussing different ways of using these YAML tags to do work with various python modules. It makes it convenient to store Path-Like objects as well as with using the pkg_resources module.)

PyYaml Documentation

YAML tag Python type
Standard YAML tags  
!!null None
!!bool bool
!!int int or long (int in Python 3)
!!float float
!!binary str (bytes in Python 3)
!!timestamp datetime.datetime
!!omap, !!pairs list of pairs
!!set set
!!str str or unicode (str in Python 3)
!!seq list
!!map dict
Python-specific tags  
!!python/none None
!!python/bool bool
!!python/bytes (bytes in Python 3)
!!python/str str (str in Python 3)
!!python/unicode unicode (str in Python 3)
!!python/int int
!!python/long long (int in Python 3)
!!python/float float
!!python/complex complex
!!python/list list
!!python/tuple tuple
!!python/dict dict
Complex Python tags  
!!python/name:module.name module.name
!!python/module:package.module package.module
!!python/object:module.cls module.cls instance
!!python/object/new:module.cls module.cls instance
!!python/object/apply:module.f value of f(...)

Use Case Examples

Importing Data files

Python implementation

from pkg_resources import resource_filename
from Datasnakes.Manager.config import references
path = resource_filename(references.__name__, "Local_Reliability_Measures_from_Sets_of_Co-optimal_Multiple_Sequence_Alignments.pdf")

YAML implementation

path: '!!python/object/apply:pkg_resources.resource_filename [Datasnakes.Manager.config.references, "Local_Reliability_Measures_from_Sets_of_Co-optimal_Multiple_Sequence_Alignments.pdf"]'

Importing path-like objects

Python implementation

from pathlib import Path
NCBI_refseq_release = Path('NCBI/refseq/release') 

YAML implementation

NCBI_refseq_release: "!!python/object/apply:pathlib.Path ['NCBI/refseq/release']"
@grabear grabear mentioned this issue Nov 9, 2017
@grabear grabear self-assigned this Nov 9, 2017
@grabear grabear added this to the Official project release milestone Nov 9, 2017
@sdhutchins sdhutchins added this to To Do in Official Release Nov 14, 2017
@grabear
Copy link
Member Author

grabear commented Jan 18, 2018

Currently doing this with #95.

@grabear
Copy link
Member Author

grabear commented May 20, 2019

This has been perfected in our workflows. Especially with the most recent PR #145

@grabear grabear closed this as completed May 20, 2019
Official Release automation moved this from To Do to Done May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants