Run a Lumen Dashboard

Hi

I am trying Lumen Dashboard, and i am running a example from Build a dashboard — Lumen 0.14.2 documentation
But it end up with:

ERROR: Error loading penguins.yaml:

Invalid syntax in 'penguins.yaml' on line 1:
sources:

Traceback (most recent call last):
  File "c:\python38\lib\site-packages\bokeh\application\handlers\code_runner.py", line 106, in __init__
    nodes = ast.parse(source, os.fspath(path))
  File "c:\python38\lib\ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
  File "penguins.yaml", line 1
    sources:
           ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Any suggestion will be grateful.

Kind regard
Victor

Can you try to delete and write the colon yourself?

Hi Hoxbro

Thanks for you suggestion, I tried to remove the Colon and write myself, And still get the same error massgae.
I think it would be batter for me paste the code here to see if anyone have same error:

sources:

  penguin_source:
  
    type: file
    
    tables:
    
      penguin_table: https://datasets.holoviz.org/penguins/v1/penguins.csv


layouts:

  - title: Penguins

    source: penguin_source

    views:

      - type: table

        table: penguin_table

When creating the file, are you using Windows / Mac / Linux? I think it might be something with encoding the empty spaces.

sublimetext2 - Fixing Sublime Text 2 line endings? - Stack Overflow

1 Like

hi ahuang11

Thanks for your help. That works for me. Thanks

Kind regards
Victor

Hi @ahuang11,

Same issue here, but the proposed solution didn’t work.

Using Win10, conda. With notepad++ I create the YAML file, change end of line to unix (LF) and save it, but still getting the same message when running lumen serve penguins.yaml --show --autoreload

Thanks in advance.

Are you experiencing the exact same traceback, or somewhat different?

Same trace with CRLF, CR or LF end of lines (at least using Notepad++):

ERROR: Error loading penguins.yaml:

Invalid syntax in 'penguins.yaml' on line 1:
sources:

Traceback (most recent call last):
  File "C:\Users\rrr\miniconda3\lib\site-packages\bokeh\application\handlers\code_runner.py", line 106, in __init__
    nodes = ast.parse(source, os.fspath(path))
  File "C:\Users\rrr\miniconda3\lib\ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "penguins.yaml", line 1
    sources:
            ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escapeThis text will be hidden

The penguins.yaml content is:

layouts:
  - title: Penguins
    source: penguin_source
    views:
      - type: table
        table: penguin_table

Maybe you can click show all characters in notepad++ Text Editor which shows \r\n? - Stack Overflow

Yes, I did check that the character is actually changing to LF, even it could be seen in plain Notepad.

I have tried debugging and have been able to fix it. It seems that YamlHanlder generates a path in Windows mode using backslashes. Forcing the path to be posix in this line of this file works:
filename = Path(os.path.abspath(kwargs['filename'])).as_posix()

Thanks again and I hope it can be helpful to anyone who has the same problem.

Thank you for the investigation @rrr.

This is a bug! Have fixed it here: Fix path handling on Windows · holoviz/lumen@af86b04 · GitHub

2 Likes