GithubHelp home page GithubHelp logo

Maybe switch to strictyaml? about yacron HOT 8 CLOSED

gjcarneiro avatar gjcarneiro commented on August 23, 2024
Maybe switch to strictyaml?

from yacron.

Comments (8)

gjcarneiro avatar gjcarneiro commented on August 23, 2024

I created the stricyaml branch with work on this, but I couldn't get it to work in the end. I am not impressed. I think I'll stick to normal yaml and jsonschema.

from yacron.

crdoconnor avatar crdoconnor commented on August 23, 2024

Thanks for trying. I'll take a look a bit later this evening and see if I can figure out what went wrong and issue a pull request.

From a cursory glance it looks pretty much exactly as I'd expect.

from yacron.

crdoconnor avatar crdoconnor commented on August 23, 2024

You simply missed out the Seq. Instead of::

jobs:
  - name: test-01
    command: echo "foobar"  # runs with /bin/bash as shell
    schedule: "*/5 * * * *"
  - name: test-02  # runs with /bin/sh as shell
    command: echo "zbr"
    schedule: "*/5 * * * *"

It was expecting::

jobs:
  name: test-01
  command: echo "foobar"  # runs with /bin/bash as shell
  schedule: "*/5 * * * *"

from yacron.

gjcarneiro avatar gjcarneiro commented on August 23, 2024

Oh, wow, thanks for debugging! I was just confused I guess.
I'll play around with it some more, then.

from yacron.

gjcarneiro avatar gjcarneiro commented on August 23, 2024

Btw, I would like instead of

strictyaml.exceptions.YAMLValidationError: while parsing a mapping
unexpected key not in schema 'killTimeoutx'
  in "<unicode string>", line 73, column 1:
      killTimeoutx: '0.5'
    ^ (line: 73)

to display the correct file name instead of <unicode string>. If you have any idea, would appreciate the tip. I'm doing this hack, but it feels dirty:

    try:
        doc = strictyaml.load(data, CONFIG_SCHEMA).data
    except YAMLValidationError as ex:
        if ex.context_mark is not None:
            ex.context_mark.name = path
        if ex.problem_mark is not None:
            ex.problem_mark.name = path
        raise

from yacron.

crdoconnor avatar crdoconnor commented on August 23, 2024

Fair point. I'm mulling over doing this::

try:
    doc = strictyaml.load(data, CONFIG_SCHEMA, label=path).data
except YAMLValidationError as ex:
    print(ex)

strictyaml.exceptions.YAMLValidationError: while parsing a mapping
unexpected key not in schema 'killTimeoutx'
  in "/path/to/whatever.yaml", line 73, column 1:
      killTimeoutx: '0.5'
    ^ (line: 73)

from yacron.

gjcarneiro avatar gjcarneiro commented on August 23, 2024

That could work, though perhaps it would be simpler to just give it a file name and let strictyaml open the file.

Are you designing this as a new API for strictyaml? Should we discuss in a new strictyaml issue, instead of this (closed) issue?

from yacron.

crdoconnor avatar crdoconnor commented on August 23, 2024

Raised: crdoconnor/strictyaml#26

Re: opening the file - no, I don't really want to do that. It opens up a whole new can of worms (encoding errors, various file system related exceptions, etc.) that I don't really want to become strictyaml's problem.

from yacron.

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.