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

Migrated docs form Mintlify to MkDocs #122

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions docs/cli/deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
title: "preswald deploy"
icon: octicons/code-24
description: "Deploy your app to a cloud environment or a local container."
---

# `preswald deploy <file_name>`

The `preswald deploy` command deploys your application to a desired environment, such as Structured Cloud, Google Cloud Platform, or a local container. It streamlines the deployment process, handling configuration and execution seamlessly.

Note: `preswald deploy` creates a `.env.structured` in the current directory for Structured Cloud deployments that is useful for `preswald stop` and `preswald deployments`.

## Arguments

- **`file_name` (str):**
The path to the Python script that contains your application code. This is the script to be deployed.

## Options

- **`--target`**: Specifies the deployment target. Options include:
- `structured`: Deploys to Structured Cloud. Requires Structured API Key.
- `gcp`: Deploys to Google Cloud Platform. Requires GCloud CLI installed.
- `local` (default): Builds and runs a container locally without deploying to the cloud.
- **`port` (int):**
The port on which to run the Preswald server. Default is 8501
- **`log-level` (str):**
The log level for the Preswald server. Options are DEBUG, INFO, WARNING, ERROR, CRITICAL. Default is INFO
- **`github` (str):**
Github username (what you used to create your structured account with).
- **`api-key` (str):**
Structured API Key. See console.structuredlabs.com for account and org details.

---

## Requirements for Cloud Deployment

- **Structured Cloud Deployment:**
Get an API key from Settings at https://console.structuredlabs.com. The CLI will provide guidance on setup.
- **Google Cloud Deployment:**
Install the [GCloud CLI](https://cloud.google.com/sdk/docs/install). If not, the CLI will provide guidance on setup.

---

## Example Deployment Commands

### 1. **Structured Cloud Deployment**

To deploy your app to Structured Cloud:

```bash
preswald deploy --target structured --github <github-username> --api-key <structured-api-key> hello.py
```

This command packages your app into a container and deploys it to Structured Cloud, providing a shareable live preview link.

---

### 2. **Google Cloud Run Deployment**

To deploy your app to Google Cloud Run:

```bash
preswald deploy --target gcp hello.py
```

This command packages your app into a container and deploys it to Google Cloud Run, providing a shareable live preview link.

---

### 3. **AWS Deployment** (Coming soon!)

To deploy your app to AWS:

```bash
preswald deploy --target aws hello.py
```

Install and configure AWS CLI before running this command.

---

### 4. **Local Deployment (Dry Run)**

To build and test your app locally without deploying it to the cloud:

```bash
preswald deploy --target local hello.py
```

This creates a container locally for testing purposes.

---

### 5. **Default Deployment**

If no `--target` is specified, the deployment defaults to local execution:

```bash
preswald deploy hello.py
```

This builds and runs your app in a local container.

---

## What Preswald Handles

- **Cloud Deployment:** Automates the process of containerizing your app, configuring the environment, and deploying it to the target platform.
- **Local Testing:** Builds a container locally to let you verify your app before cloud deployment.
- **Live Preview:** Provides a shareable URL (for cloud deployments) so others can interact with your app.

---

With `preswald deploy`, you can transition from local testing to cloud deployment in a few simple steps, making your app accessible to a broader audience.
17 changes: 17 additions & 0 deletions docs/cli/deployments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: "preswald deployments"
icon: octicons/code-24
description: "List all deployments on Structured Cloud."
---

# `preswald deployments`

The `preswald deployments` command reads the current structured API Key from `.env.structured` (created during `preswald deploy --target structured ...`).

Only works for deployments on Structured Cloud.

## Example Usage

```bash
preswald deployments
```
33 changes: 33 additions & 0 deletions docs/cli/init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: "preswald init"
icon: octicons/code-24
description: "Initialize a new project directory with boilerplate files."
---

# `preswald init <project_name>`

The `preswald init` command initializes a new project directory and generates boilerplate files to get started quickly.

## Arguments

- **`project_name` (str):**
The name of the new project.

## Example Usage

```bash
preswald init my_app
```

## Generated Files

When you run the `preswald init` command, the following files are created in the project directory:

- **`hello.py`:** Starter application script.
- **`preswald.toml`:** Configuration file for your app.
- **`secrets.toml`:** Secure file for storing sensitive data.
- **`README.md`:** Simple introduction to the preswald project.
- **`data/`:** Directory for some sample data.
- **`images/`:** Directory with logo, favicon, and readme gif.

Start building your project with these preconfigured files to save time and effort.
72 changes: 72 additions & 0 deletions docs/cli/run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: "preswald run"
icon: octicons/code-24
description: "Launch a local development server for your data app."
---

# `preswald run <file_name>`

The `preswald run` command launches a local development server for your application, enabling you to test and interact with your app in a browser.

## Arguments

- **`file_name` (str):**
The path to the Python script that contains your application code. This is the script the development server will execute.

## Options

- **`port` (int):**
The port on which to run the Preswald server. Default is 8501
- **`log-level` (str):**
The log level for the Preswald server. Options are DEBUG, INFO, WARNING, ERROR, CRITICAL. Default is INFO
- **`disable-new-tab` (bool):**
Flag which controls whether or not a new browser window pops up to show the rendered data app. Default is false, which means that a new window will pop up.


---

## Example Usage

To launch the development server for your app:

```bash
preswald run hello.py
```

or

```bash
preswald run hello.py --port 8504 --log-level DEBUG --disable-new-tab
```

After running the command, your application will be available locally at:

```plaintext
http://localhost:8501
```

## Detailed Explanation

### 1. **Launching the Server**

When you run the command, `preswald` starts a local development server using the specified Python script. This allows you to quickly preview and debug your app in a controlled environment.

### 2. **Supported Script Format**

Any Python file containing valid application logic can be used.

### 3. **Localhost Access**

The app is hosted on `localhost`, which is a local server accessible only from your machine. Use the provided URL to interact with your app through a browser.

### 4. **Stopping the Server**

To stop the server, press `Ctrl+C` in the terminal where the command is running.

### 5. **Error Handling**

If the script cannot be executed (e.g., due to missing dependencies or syntax errors), `preswald` will provide helpful error messages to guide you.

---

Use the `preswald run` command to test, iterate, and debug your app effortlessly in a local environment.
30 changes: 30 additions & 0 deletions docs/cli/stop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: "preswald stop"
icon: octicons/code-24
description: "Stop a deployed app."
---

# `preswald stop`

The `preswald stop` command stops an already deployed app.

Note: `preswald deploy` creates a `.env.structured` in the current directory for Structured Cloud deployments. This is used under the hood to stop Structured deployments.

## Arguments

- **`file_name` (str):**
The path to the Python script that contains your application code. This is the script of which app was deployed.

## Options

- **`--target`**: Specifies the deployment target. Options include:
- `structured`: Structured Cloud. Requires Structured API Key.
- `gcp`: Google Cloud Platform. Requires GCloud CLI installed.
- `local` (default): Locally without deploying to the cloud.


## Example Usage

```bash
preswald stop --target structured hello.py
```
15 changes: 15 additions & 0 deletions docs/cli/tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "preswald tutorial"
icon: octicons/code-24
description: "Run a tutorial preswald project bundled with the package."
---

# `preswald tutorial`

The `preswald tutorial` command starts up a local preswald server for a tutorial app.

## Example Usage

```bash
preswald tutorial
```
Loading