databio / bulker

Manager for multi-container computing environments
https://bulker.io
BSD 2-Clause "Simplified" License
24 stars 2 forks source link

NameError: global name 'FileNotFoundError' is not defined #47

Closed lwaldron closed 4 years ago

lwaldron commented 4 years ago

Should I upgrade to Python 3?

$ bulker load demo
Bulker config: /Users/lwaldron/bulker_config.yaml
Got URL: http://hub.bulker.io/bulker/demo.yaml
That manifest has already been loaded. Overwrite? [y/N] y
Removing all executables in: /Users/lwaldron/bulker_crates/bulker/demo/default
Traceback (most recent call last):
  File "/usr/local/bin/bulker", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/bulker/bulker.py", line 742, in main
    force=args.force)
  File "/usr/local/lib/python2.7/site-packages/bulker/bulker.py", line 304, in bulker_load
    except FileNotFoundError:
NameError: global name 'FileNotFoundError' is not defined
Levis-MBP:_pages lwaldron$ bulker -h
version: 0.4.0
usage: bulker [-h] [-V] [--commands] [--verbosity V] [--silent] [--logdev]
              {load,run,init,activate,list} ...

bulker - manage containerized executables

positional arguments:
  {load,run,init,activate,list}
    load                Load a crate from a manifest
    run                 Run a command in a crate
    init                Initialize a new bulker config file
    activate            Activate a crate by adding it to PATH
    list                List available bulker crates

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  --commands            show program's version number and exit
  --verbosity V         Set logging level (1-5 or logging module level name)
  --silent              Silence logging. Overrides verbosity.
  --logdev              Expand content of logging message format.

https://bulker.databio.org
$ 
lwaldron commented 4 years ago

From a Linux server I'm getting this. It's probably time for me to upgrade to Python3 anyways, just let me know if that's what I need to do.

$ bulker load demo
Bulker config: /home/lwaldron/git/config/bulker_config.yaml
Got URL: http://hub.bulker.io/bulker/demo.yaml
Traceback (most recent call last):
  File "/home/lwaldron/.local/bin/bulker", line 8, in <module>
    sys.exit(main())
  File "/home/lwaldron/.local/lib/python2.7/site-packages/bulker/bulker.py", line 719, in main
    assert(os.path.exists(exe_template))
AssertionError
$ bulker -h
version: 0.4.0
usage: bulker [-h] [-V] [--commands] [--verbosity V] [--silent] [--logdev]
              {load,run,init,activate,list} ...

bulker - manage containerized executables

positional arguments:
  {load,run,init,activate,list}
    load                Load a crate from a manifest
    run                 Run a command in a crate
    init                Initialize a new bulker config file
    activate            Activate a crate by adding it to PATH
    list                List available bulker crates

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  --commands            show program's version number and exit
  --verbosity V         Set logging level (1-5 or logging module level name)
  --silent              Silence logging. Overrides verbosity.
  --logdev              Expand content of logging message format.

https://bulker.databio.org
$ python --version
Python 2.7.17
$ 
nsheff commented 4 years ago

Yep that's a bug in bulker for python2. I was trying to keep it python 2 compatible, but I think I am going to stop supporting python 2... I think the time has come to move to python 3...

But you wouldn't get this error unless the crate folder was moved outside of bulker. So, it shouldn't come up very frequently. If you create the folder

mkdir /Users/lwaldron/bulker_crates/bulker/demo/default

it might go away...

Also, FYI, there have been some major changes on the dev branch of bulker.

nsheff commented 4 years ago

For the linux server one -- did you initialize bulker? is there a 'templates' directory? That exe template is created when bulker is initialized.

nsheff commented 4 years ago

That's not a python 2 problem. See how I can reproduce it:

nsheff@zither:~$ bulker init -c abc
Guessing container engine is docker.
Wrote new configuration file: abc
nsheff@zither:~$ rm -rf templates/
nsheff@zither:~$ bulker load -c abc demo
Bulker config: /home/nsheff/abc
Traceback (most recent call last):
  File "/home/nsheff/.local/bin/bulker", line 10, in <module>
    sys.exit(main())
  File "/home/nsheff/.local/lib/python2.7/site-packages/bulker/bulker.py", line 820, in main
    assert(os.path.exists(exe_template))
AssertionError

If I remove the templates, then it won't work. Do you havea config file, but the templates it points to is not there?

nsheff commented 4 years ago

Tr this:

bulker --verbosity 5 load demo

and make sure your executable template exists

nsheff commented 4 years ago

Ok, the first issue is now fixed on python 2 in dev branch, and I added a test (but beware -- there are many other changes on dev. So you may run into other issues).

And the second issue is actually a configuration problem you're having. I've improved the error messages on the dev branch.

Are you at a point you could test out the dev branch? It's working great for me here on multiple systems, but I haven't been able to test the zshell connection very much. It adds some new cool features like bulker inspect and also does a much better job with prompts (though this is still experimental)

lwaldron commented 4 years ago

Yep I'll be happy to test the dev branch. Can you give the install command? And thanks for troubleshooting my configuration problem, my fault.

nsheff commented 4 years ago

some flavor of:

pip install --user --upgrade https://github.com/databio/bulker/archive/dev.zip
nsheff commented 4 years ago

it will be easiest if you re-initialize, since it will populate a few new config options -- keep your old config if you have crates or settings you want to copy over.

lwaldron commented 4 years ago

Thanks @nsheff - doing that and upgrading to Python 3 now...

lwaldron commented 4 years ago

(UPDATE - never mind, my syntax error with spacing in the yaml file)

Running Python 3 and bulker 0.5.0-dev. Things seem to work, except when I add my tool_args section back to my bulker_config.yaml. Then I get a bunch of errors (testing OSX now):

Levis-MBP:~ lwaldron$ bulker activate demo
Traceback (most recent call last):
  File "/Users/lwaldron/Library/Python/3.7/bin/bulker", line 8, in <module>
    sys.exit(main())
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/bulker/bulker.py", line 741, in main
    bulker_config = yacman.YacAttMap(filepath=bulkercfg, writable=False)
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yacman/yacman.py", line 84, in __init__
    file_contents = load_yaml(filepath)
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yacman/yacman.py", line 389, in load_yaml
    return read_yaml_file(filepath)
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yacman/yacman.py", line 366, in read_yaml_file
    data = yaml.safe_load(f)
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/Users/lwaldron/Library/Python/3.7/lib/python/site-packages/yaml/parser.py", line 439, in parse_block_mapping_key
    "expected <block end>, but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block mapping
  in "/Users/lwaldron/bulker_config.yaml", line 1, column 1
expected <block end>, but found '<block mapping start>'
  in "/Users/lwaldron/bulker_config.yaml", line 22, column 2
Levis-MBP:~ lwaldron$ 
lwaldron commented 4 years ago

Never mind, I introduced a spacing error! Correcting.