Code Monkey home page Code Monkey logo

Comments (3)

imrehg avatar imrehg commented on June 20, 2024

Digging a bit more, I guess this might be actually misunderstanding, as seems like I was using --env incorrectly:

If the env var is just applied as a normal env var, things work:

$ DEBUG=true bonobo run debugtest.py
DEBG:0000:stevedore.extension: found extension EntryPoint.parse('convert = bonobo.commands.convert:ConvertCommand')
DEBG:0000:stevedore.extension: found extension EntryPoint.parse('download = bonobo.commands.download:DownloadCommand')
DEBG:0000:stevedore.extension: found extension EntryPoint.parse('examples = bonobo.commands.examples:ExamplesCommand')
DEBG:0000:stevedore.extension: found extension EntryPoint.parse('init = bonobo.commands.init:InitCommand')
DEBG:0000:stevedore.extension: found extension EntryPoint.parse('inspect = bonobo.commands.inspect:InspectCommand')
DEBG:0000:stevedore.extension: found extension EntryPoint.parse('run = bonobo.commands.run:RunCommand')
DEBG:0000:stevedore.extension: found extension EntryPoint.parse('version = bonobo.commands.version:VersionCommand')
DEBG:0000:root: Command: run Arguments: {'command': 'run', 'file': 'debugtest.py', 'mod': None, 'default_env_file': None, 'default_env': None, 'env_file': None, 'env': None, 'quiet': False, 'verbose': False, 'install': False}
<Setting DEBUG=True>
<Setting PROFILE=False>
DEBG:0000:root: Creating execution strategy 'threadpool'...
DEBG:0000:bonobo.execution.contexts.node: Node loop starts for <NodeExecutionContext(+extract)>.
DEBG:0000:bonobo.execution.contexts.node: Node loop ends for <NodeExecutionContext(-extract) in=1 out=1>.
 - extract(0) in=1 out=1 [done] 

(not exactly the same --debug, actually it gives more logs)

The confusion was:

  • for DEBUG, either DEBUG=True bonobo run .... or bonobo --debug run ... has to be used, --env DEBUG=True doesn't take effect
  • for other variables, ENV=something bonobo ... or bonobo run --env ... (or other environment settings that are available) can be used, but --env shouldn't really be used for this, but env vars for the actual graph....

This might warrant some documentation clarifications, but does not feel like a bug anymore, sorry for the noise!

from bonobo.

hartym avatar hartym commented on June 20, 2024

The issue you faced is because arguments are parsed by bonobo.parse_args(parser).

You should be able to see the values you wanted to see if you do print(bonobo.settings.DEBUG) within the with block. If this does not work, then it's a bug.

from bonobo.

imrehg avatar imrehg commented on June 20, 2024

Retried again, moving the test inside the with block:

# debugtest.py
import bonobo

def extract():
    yield "test"

if __name__ == "__main__":
    parser = bonobo.get_argument_parser()
    with bonobo.parse_args(parser) as options:
        print(bonobo.settings.DEBUG)
        bonobo.run(bonobo.Graph(extract), services={})

resulting in these outcomes of the 4 different cases of applying env vars, that I understood:

  • DEBUG=true bonobo run debugtest.py, DEBUG env var is set ✅
  • bonobo --debug run debugtest.py, DEBUG env var is set ✅
  • bonobo run debugtest.py --env DEBUG=true, DEBUG env var is not set (stays default false) ❌
  • bonobo run debugtest.py --env-file env (with env containing DEBUG=true) DEBUG env var is not set (stays default false) ❌

from bonobo.

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.