Coder Social home page Coder Social logo

Comments (23)

mirkobunse avatar mirkobunse commented on July 22, 2024 2

The PR is open

from yaml.jl.

peng1999 avatar peng1999 commented on July 22, 2024 2

And maybe maintainer of this package should bump a new release.

from yaml.jl.

mirkobunse avatar mirkobunse commented on July 22, 2024 2

Hi everyone,

with the release v0.4.2 it is now possible to read and write arbitrary subtypes of AbstractDict. With this feature, you can maintain the order of YAML files in a load-save-load roundtrip. All you need to do is to use the new dicttype argument while reading, which is documented in the README.

from yaml.jl.

sglyon avatar sglyon commented on July 22, 2024 1

Not sure, that was my mistake. Sorry about that

from yaml.jl.

mirkobunse avatar mirkobunse commented on July 22, 2024 1

I did make a Julia implementation of writing YAML files: https://github.com/mirkobunse/ComfyCommons.jl/blob/master/src/yaml.jl

If there is still interest and a maintainer willing to review, I'll prepare a pull request from this sketch.

What it already does:

  • Write Dicts and Vectors
  • Write Strings, Numbers, and so on
  • Correct and nice intendation
  • A prefix string with comments can be written along with the config

What is currently missing:

  • The order of the Dict entries in the written file is arbitrary. Keeping the order of an existing file would require YAML.jl to use ordered dictionaries, which will be easy to do in a PR.
  • Comments at arbitrary positions

EDIT: Of course, the Dicts and Vectors can be nested.

from yaml.jl.

mirkobunse avatar mirkobunse commented on July 22, 2024 1

Sure, I can open a PR on YAML.jl to make a direct contribution. Thank you, @mlhetland, for keeping an eye on the licenses.

from yaml.jl.

femtotrader avatar femtotrader commented on July 22, 2024

YAML.yaml(...) will be great!
(like JSON.json(...))

from yaml.jl.

trans avatar trans commented on July 22, 2024

Why was this closed without an answer?

from yaml.jl.

trans avatar trans commented on July 22, 2024

I wish I had the time/knowledge to whip this out myself, but at this point I do not -- it would be much easier for someone else with the right knowledge to do it. Yet I really would like to have this functionality, so I am willing to kick in $20 to start a bounty in hopes that it will incentivize the right person. Maybe a few others can kick in as well.

from yaml.jl.

jdlangs avatar jdlangs commented on July 22, 2024

I'll have lots of time available for open-source come mid-December and was planning to devote some of it here so I won't mind working on an implementation for this around then if no one else has done it. No need for a bounty on my end.

Before that though, it would be good to clear up why no development has happened on this package in over a year even though multiple pull requests are open.

from yaml.jl.

sglyon avatar sglyon commented on July 22, 2024

@jdlangs that'd be great.

I think the long break since this has been actively worked on is due to two main things: @dcjones (the author of this package) getting working on his PhD and the YAML parsing routines being stable.

@dcjones has given me permissions for this repo, so I can manage it going forward. I don't have much time to implement new features myself, but will be able to view/merge pull requests.

from yaml.jl.

jdlangs avatar jdlangs commented on July 22, 2024

Sounds good, and thanks for stepping up to manage the development. It provides a lot of assurance to potential contributors that there's an active maintainer, even if they aren't able to add features themself.

On the same note, aren't there a few pull requests that should have been merged quite a while ago? I'll point out #32 in particular.

from yaml.jl.

dreammaker avatar dreammaker commented on July 22, 2024

@jdlangs, did you (or anyone else) make progress on this?

from yaml.jl.

montyvesselinov avatar montyvesselinov commented on July 22, 2024

from yaml.jl.

chakravala avatar chakravala commented on July 22, 2024

It would be great if this could be implemented

from yaml.jl.

mlhetland avatar mlhetland commented on July 22, 2024

I've had a look at this, and I guess the amount of effort involved would be closely correlated with the level of ambition.

On the one hand, a simple YAML-emitting mechanism mirroring that of JSON.jl could probably be done in a matter of hours. On the other hand, there is a spectrum of stretch-goals, here. For example, one might want to let the user determine which syntax variants are used to serialize different components, and perhaps include line wrapping as part of the pretty-printing (taking indentation, etc., into account). And, perhaps more usefully, one might want to be able to preserve metadata when parsing, so that one could emit the same syntax forms, and even include the same insignificant whitespace, comments, etc., so that round-tripping via YAML.jl does not modify the YAML file, and any modifications are local to what is modified, leaving the rest of the file (including comments, etc.) intact. As far as I know, there are tools that do this – but that would require quite a bit more work. I guess one could have a list of features, and see if it's possible to map out an incremental path from the simple emitter to the more integrated library where parser and emitter cooperate, using the same data model (including non-significant information about order, whitespace, comments, syntax variants…).

Another thing I've thought about now and then is whether it might be useful to go the PyYAML route, and simply wrap LibYAML. Of course, that introduces a black box, which is sort of un-Julian, and the conversion to/from Julia types would still have to be there. So maybe it's not that much more useful.

from yaml.jl.

mlhetland avatar mlhetland commented on July 22, 2024

Using ordered dictionaries would be very useful, I think – even though the YAML spec specifically doesn't care about ordering, in applications it can be quite useful if a library supports it. (Specifically having round-tripping, i.e., reading and then writing, not modify things too much. Ideally, it would preserve comments etc., as well, but I guess that requires a richer internal model.)

from yaml.jl.

babaq avatar babaq commented on July 22, 2024

is there any plans or progress to implement Yaml writing, or just try to incorporate the code @mirkobunse have write?

from yaml.jl.

mlhetland avatar mlhetland commented on July 22, 2024

If @mirkobunse's code is to be used, I guess it would have to be released under some other license, or contributed directly to the YAML.jl project (by @mirkobunse)? At present, it's licensed under GPL 3, and YAML.jl is under MIT.

from yaml.jl.

peng1999 avatar peng1999 commented on July 22, 2024

@kescobo This issue can be closed since #68 has merged.

from yaml.jl.

CiaranOMara avatar CiaranOMara commented on July 22, 2024

@mirkobunse, regarding the ordering, TOML has an option to sort when printing.

from yaml.jl.

mirkobunse avatar mirkobunse commented on July 22, 2024

Thanks for the hint!

However, TOML seems to sort lexicographically. The order in a YAML file can be any order. The preservation of such requires some kind of an ordered dictionary. DataStructures.jl has one, by the way.

from yaml.jl.

CiaranOMara avatar CiaranOMara commented on July 22, 2024

I think ordered dictionaries were split off into OrderedCollections.jl.

from yaml.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.