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

Add CLI API #3

Closed
wants to merge 28 commits into from
Closed

Add CLI API #3

wants to merge 28 commits into from

Conversation

pankgeorg
Copy link
Member

CLI API:
(Web API coming soon!)

usage: <PROGRAM> [--host HOST] [--port PORT] [--dry-run]
                 [--notebook_paths [NOTEBOOK_PATHS...]]
                 [--skip-run-notebooks [SKIP-RUN-NOTEBOOKS...]]
                 [--export] [--export-only]
                 [--export-exclude [EXPORT-EXCLUDE...]] [--enable-ui]
                 [--separate-pluto-state] [--binder-url BINDER-URL]
                 [--slider-server-url SLIDER-SERVER-URL]
                 [--cache-dir CACHE-DIR] [--output-dir OUTPUT-DIR]
                 [-c CONFIG] [--sample-toml SAMPLE-TOML]
                 [--enable-api] [--secret SECRET] [--version] [-h]
                 [start_dir]

Pluto Slide Server. A boutique pluto-notebook runner that gives life
to your static exports.
Can respond to @bind macros updates but also just create static
exports that look cool.

positional arguments:
  start_dir             The starting directory (default: ".")

optional arguments:
  --host HOST           host:port (default: "127.0.0.1")
  --port PORT           port (type: Int64, default: 2345)
  --dry-run             Stop the the slider server after running once.
                        Useful in conjuction with --export.
  --notebook_paths [NOTEBOOK_PATHS...]
                        The paths in which to look for notebooks
                        (type: Vector{String})
  --skip-run-notebooks [SKIP-RUN-NOTEBOOKS...]
                        list of notebook files to skip from running.
                        (type: Vector{String})
  --export              also export static files
  --export-only         Same as --export --dry-run
  --export-exclude [EXPORT-EXCLUDE...]
                        Export option. list of notebook files to skip
                        from exporting (type: Vector{String})
  --enable-ui           Export option. Don't hide all buttons and
                        toolbars. Without this flag, they will be
                        hidden by default to make the page look like
                        an article
  --separate-pluto-state
                        Export option. If set this flag splits the
                        export to two files: a .plutostate and an
                        .html. Default is to have state 'baked in' the
                        file'
  --binder-url BINDER-URL
                        Export option. This will set the binder URL
                        that will be used as a backend. MIT Math uses:
                                                https://mybinder.org/v2/gh/mitmath/18S191/e2dec90
                        (default: "")
  --slider-server-url SLIDER-SERVER-URL
                        Export option. The URL of the slider server
                        which can respond to requests of @bind
                        elements
  --cache-dir CACHE-DIR
                        if provided, use this directory to read and
                        write cached notebook states. Caches will be
                        indexed by notebook hash, but you need to take
                        care to invalidate the cache when Pluto or
                        this export script updates. Useful in
                        combination with
                        https://github.com/actions/cache.
  --output-dir OUTPUT-DIR
                        folder to write generated HTML files to (will
                        create directories to preserve the input
                        folder structure). Leave at the default to
                        generate each HTML file in the same folder as
                        the notebook file. (default: ".")
  -c, --config, --configuration_file CONFIG
                        Use this option to provide a configuration
                        TOML
  --sample-toml SAMPLE-TOML
                        Print a sample TOML configuration file
  --enable-api          Allow API requests
  --secret SECRET       Web API secret
  --version             show version information and exit
  -h, --help            show this help message and exit

Panagiotis Georgakopoulos added 2 commits March 26, 2021 12:49
@pankgeorg
Copy link
Member Author

To test the cli, run this at the project where you dev Pluto & PlutoBindServer:
julia --project=. -e "using PlutoSliderServer; cli()" -- --help (note the -- before --help)

@fonsp
Copy link
Member

fonsp commented Mar 26, 2021

Wow!!

@fonsp
Copy link
Member

fonsp commented Mar 26, 2021

We could use https://github.com/Roger-luo/Comonicon.jl if it's useful

@fonsp fonsp changed the title Add CLI API, Web API Add CLI API Mar 26, 2021
src/WebAPI.jl Outdated

function path_hash(path)
myhash(open(f -> read(f, String), path))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

myhash(read(path))

@pankgeorg
Copy link
Member Author

image
!!!!

Panagiotis Georgakopoulos added 2 commits April 19, 2021 23:00
- Respect options when they exist at
`reporoot/pluto-deployment-environment/PlutoDeployment.toml`

- Export
- Write index file
- Respect configuration 'don't run'
src/WebAPI.jl Outdated
@info "Bond connections" showall(collect(bond_connections))
session = RunningNotebookSession(;
path=path,
hash=path_hash(path),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug!

return HTTP.Response(501, "Can't pull")
end
start_dir = "$this_folder/$folder"
settings, pluto_options = get_configuration("$this_folder/$folder/pluto-deployment-environment/PlutoDeployment.toml")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that is different, restart
write a file (.env~!!!~~~) that the process will find after boot
and run shutdown()

Panagiotis Georgakopoulos added 2 commits April 22, 2021 17:16
@pankgeorg pankgeorg closed this Apr 23, 2021
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

Successfully merging this pull request may close these issues.

2 participants