Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with showman execute #1

Open
psads-git opened this issue Jul 16, 2024 · 0 comments
Open

Errors with showman execute #1

psads-git opened this issue Jul 16, 2024 · 0 comments

Comments

@psads-git
Copy link

I am trying to use showman to execute a python script:

/home/x/myenv/bin/showman execute x.typ 

but getting the following errors:

Traceback (most recent call last):
  File "/home/x/myenv/bin/showman", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/x/myenv/lib64/python3.12/site-packages/showman/__main__.py", line 21, in main
    return fire.Fire(
           ^^^^^^^^^^
  File "/home/x/myenv/lib64/python3.12/site-packages/fire/core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/x/myenv/lib64/python3.12/site-packages/fire/core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "/home/x/myenv/lib64/python3.12/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/x/myenv/lib64/python3.12/site-packages/showman/executer.py", line 341, in execute
    runner = CodeRunner(root_dir or os.getcwd(), config=config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/x/myenv/lib64/python3.12/site-packages/showman/executer.py", line 202, in __init__
    self.workspace_cache = json.load(f)
                           ^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The document x.typ is:

#import "@preview/showman:0.1.1": runner, formatter
#set page(height: auto)

#show raw: it => {
  let kwargs = if it.block {
    (width: 100%, line-numbers: false)
  } else {
    (inline: true)
  }
  formatter.format-raw(it, ..kwargs)

}

#show <example-output>: formatter.format-raw
// #show <example-input>: formatter.format-raw

#let cache = json("/.coderunner.json").at("/x.typ", default: (:))
#let show-rule = runner.external-code.with(
  result-cache: cache,
  direction: ttb,
)

#show raw: it => {
  if it.at("label", default: none) != <continue> {
    heading(it.lang)
  }
  if it.lang != "typst" {
    show-rule(it)
  } else {
    runner.standalone-example(it, direction: ttb)
  }
}


```python
import functools

@functools.lru_cache(maxsize=None)
def fib(n):
    if n < 2:
        return n
    return fib(n-1) + fib(n-2)

fib(50)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant