EconForge/dolo.py

404 error raised by Getting Started 'Running dolo' instructions

sbenthall opened this issue · 2 comments

A 404 error is raised when running the Running dolo part of the Getting Started instructions, here:

https://dolo.readthedocs.io/en/latest/installation.html#running-dolo

To reproduce the error, with dolo installed:

$ python
Python 3.6.8 |Anaconda custom (64-bit)| (default, Dec 30 2018, 01:22:34) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from dolo import *
>>> model = yaml_import("https://github.com/EconForge/dolo/blob/master/examples/models/compat/rbc.yaml")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sb/anaconda3/lib/python3.6/site-packages/dolo/compiler/model_import.py", line 10, in yaml_import
    txt = read_file_or_url(fname)
  File "/home/sb/anaconda3/lib/python3.6/site-packages/dolo/misc/display.py", line 9, in read_file_or_url
    txt = urllib.request.urlopen(url).read()
  File "/home/sb/anaconda3/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/home/sb/anaconda3/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/home/sb/anaconda3/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/home/sb/anaconda3/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/home/sb/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/home/sb/anaconda3/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

Indeed, the URL also gets a 404 error when reached through the browser:
https://github.com/EconForge/dolo/blob/master/examples/models/compat/rbc.yaml

I tried replacing it with the most plausible alternative:
https://github.com/EconForge/dolo/blob/master/examples/models/rbc.yaml

However, this raised a different error:

>>> model = yaml_import("https://github.com/EconForge/dolo/blob/master/examples/models/rbc.yaml")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sb/anaconda3/lib/python3.6/site-packages/dolo/compiler/model_import.py", line 14, in yaml_import
    output = lint(txt)
  File "/home/sb/anaconda3/lib/python3.6/site-packages/dolo/linter.py", line 434, in lint
    raise exc
  File "/home/sb/anaconda3/lib/python3.6/site-packages/dolo/linter.py", line 431, in lint
    data = ry.load(txt, ry.RoundTripLoader)
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/main.py", line 949, in load
    return loader._constructor.get_single_data()
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/constructor.py", line 111, in get_single_data
    node = self.composer.get_single_node()
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/composer.py", line 73, in get_single_node
    self.parser.get_event()
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/parser.py", line 162, in get_event
    self.current_event = self.state()
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/parser.py", line 176, in parse_stream_start
    token.move_comment(self.scanner.peek_token())
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/scanner.py", line 1778, in peek_token
    self._gather_comments()
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/scanner.py", line 1806, in _gather_comments
    self.fetch_more_tokens()
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/scanner.py", line 283, in fetch_more_tokens
    return self.fetch_value()
  File "/home/sb/anaconda3/lib/python3.6/site-packages/ruamel/yaml/scanner.py", line 656, in fetch_value
    self.reader.get_mark(),
ruamel.yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 625, column 26:
        <!-- blob contrib key: blob_contributors:v21:2507eaf3 ... 
                             ^ (line: 625)
albop commented

Sorry, I missed that one. What you need to supply to dolo is an url which points to a yaml file. The link https://github.com/EconForge/dolo/blob/master/examples/models/rbc.yaml points to a github webpage. If you want the file it refers to you click on this page on Raw to get https://raw.githubusercontent.com/EconForge/dolo/master/examples/models/rbc.yaml

albop commented

I updated the docs.