Skip to content

Commit cdb7607

Browse files
committed
adding pdf widget, fixed json id gen
1 parent b26a4d0 commit cdb7607

File tree

21 files changed

+2076
-20
lines changed

21 files changed

+2076
-20
lines changed

docs/configuration.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ path = "https://storage.googleapis.com/test/sample_data.csv"
7979

8080
If the CSV file is located in a subdirectory, make sure the `path` is correct relative to the root directory.
8181

82+
### PDF Example: `[data.sample_pdf]`
83+
84+
#### Fields:
85+
86+
- **type:** Use `"pdf"`
87+
- **path:** Relative path to the PDF file.
88+
89+
#### Example PDF Connections:
90+
91+
[docs.report_pdf]
92+
type = "pdf"
93+
path = "docs/report.pdf"
94+
8295
### JSON Example: `[data.sample_json]`
8396

8497
You can use a JSON file as a data source with options to normalize nested structures.

examples/document/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
secrets.toml
2+
.preswald_deploy
3+
.env.structured

examples/document/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Preswald Project
2+
3+
## Setup
4+
1. Configure your data connections in `preswald.toml`
5+
2. Add sensitive information (passwords, API keys) to `secrets.toml`
6+
3. Run your app with `preswald run`

examples/document/data/iris.csv

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
"sepal.length","sepal.width","petal.length","petal.width","variety"
2+
5.1,3.5,1.4,.2,"Setosa"
3+
4.9,3,1.4,.2,"Setosa"
4+
4.7,3.2,1.3,.2,"Setosa"
5+
4.6,3.1,1.5,.2,"Setosa"
6+
5,3.6,1.4,.2,"Setosa"
7+
5.4,3.9,1.7,.4,"Setosa"
8+
4.6,3.4,1.4,.3,"Setosa"
9+
5,3.4,1.5,.2,"Setosa"
10+
4.4,2.9,1.4,.2,"Setosa"
11+
4.9,3.1,1.5,.1,"Setosa"
12+
5.4,3.7,1.5,.2,"Setosa"
13+
4.8,3.4,1.6,.2,"Setosa"
14+
4.8,3,1.4,.1,"Setosa"
15+
4.3,3,1.1,.1,"Setosa"
16+
5.8,4,1.2,.2,"Setosa"
17+
5.7,4.4,1.5,.4,"Setosa"
18+
5.4,3.9,1.3,.4,"Setosa"
19+
5.1,3.5,1.4,.3,"Setosa"
20+
5.7,3.8,1.7,.3,"Setosa"
21+
5.1,3.8,1.5,.3,"Setosa"
22+
5.4,3.4,1.7,.2,"Setosa"
23+
5.1,3.7,1.5,.4,"Setosa"
24+
4.6,3.6,1,.2,"Setosa"
25+
5.1,3.3,1.7,.5,"Setosa"
26+
4.8,3.4,1.9,.2,"Setosa"
27+
5,3,1.6,.2,"Setosa"
28+
5,3.4,1.6,.4,"Setosa"
29+
5.2,3.5,1.5,.2,"Setosa"
30+
5.2,3.4,1.4,.2,"Setosa"
31+
4.7,3.2,1.6,.2,"Setosa"
32+
4.8,3.1,1.6,.2,"Setosa"
33+
5.4,3.4,1.5,.4,"Setosa"
34+
5.2,4.1,1.5,.1,"Setosa"
35+
5.5,4.2,1.4,.2,"Setosa"
36+
4.9,3.1,1.5,.2,"Setosa"
37+
5,3.2,1.2,.2,"Setosa"
38+
5.5,3.5,1.3,.2,"Setosa"
39+
4.9,3.6,1.4,.1,"Setosa"
40+
4.4,3,1.3,.2,"Setosa"
41+
5.1,3.4,1.5,.2,"Setosa"
42+
5,3.5,1.3,.3,"Setosa"
43+
4.5,2.3,1.3,.3,"Setosa"
44+
4.4,3.2,1.3,.2,"Setosa"
45+
5,3.5,1.6,.6,"Setosa"
46+
5.1,3.8,1.9,.4,"Setosa"
47+
4.8,3,1.4,.3,"Setosa"
48+
5.1,3.8,1.6,.2,"Setosa"
49+
4.6,3.2,1.4,.2,"Setosa"
50+
5.3,3.7,1.5,.2,"Setosa"
51+
5,3.3,1.4,.2,"Setosa"
52+
7,3.2,4.7,1.4,"Versicolor"
53+
6.4,3.2,4.5,1.5,"Versicolor"
54+
6.9,3.1,4.9,1.5,"Versicolor"
55+
5.5,2.3,4,1.3,"Versicolor"
56+
6.5,2.8,4.6,1.5,"Versicolor"
57+
5.7,2.8,4.5,1.3,"Versicolor"
58+
6.3,3.3,4.7,1.6,"Versicolor"
59+
4.9,2.4,3.3,1,"Versicolor"
60+
6.6,2.9,4.6,1.3,"Versicolor"
61+
5.2,2.7,3.9,1.4,"Versicolor"
62+
5,2,3.5,1,"Versicolor"
63+
5.9,3,4.2,1.5,"Versicolor"
64+
6,2.2,4,1,"Versicolor"
65+
6.1,2.9,4.7,1.4,"Versicolor"
66+
5.6,2.9,3.6,1.3,"Versicolor"
67+
6.7,3.1,4.4,1.4,"Versicolor"
68+
5.6,3,4.5,1.5,"Versicolor"
69+
5.8,2.7,4.1,1,"Versicolor"
70+
6.2,2.2,4.5,1.5,"Versicolor"
71+
5.6,2.5,3.9,1.1,"Versicolor"
72+
5.9,3.2,4.8,1.8,"Versicolor"
73+
6.1,2.8,4,1.3,"Versicolor"
74+
6.3,2.5,4.9,1.5,"Versicolor"
75+
6.1,2.8,4.7,1.2,"Versicolor"
76+
6.4,2.9,4.3,1.3,"Versicolor"
77+
6.6,3,4.4,1.4,"Versicolor"
78+
6.8,2.8,4.8,1.4,"Versicolor"
79+
6.7,3,5,1.7,"Versicolor"
80+
6,2.9,4.5,1.5,"Versicolor"
81+
5.7,2.6,3.5,1,"Versicolor"
82+
5.5,2.4,3.8,1.1,"Versicolor"
83+
5.5,2.4,3.7,1,"Versicolor"
84+
5.8,2.7,3.9,1.2,"Versicolor"
85+
6,2.7,5.1,1.6,"Versicolor"
86+
5.4,3,4.5,1.5,"Versicolor"
87+
6,3.4,4.5,1.6,"Versicolor"
88+
6.7,3.1,4.7,1.5,"Versicolor"
89+
6.3,2.3,4.4,1.3,"Versicolor"
90+
5.6,3,4.1,1.3,"Versicolor"
91+
5.5,2.5,4,1.3,"Versicolor"
92+
5.5,2.6,4.4,1.2,"Versicolor"
93+
6.1,3,4.6,1.4,"Versicolor"
94+
5.8,2.6,4,1.2,"Versicolor"
95+
5,2.3,3.3,1,"Versicolor"
96+
5.6,2.7,4.2,1.3,"Versicolor"
97+
5.7,3,4.2,1.2,"Versicolor"
98+
5.7,2.9,4.2,1.3,"Versicolor"
99+
6.2,2.9,4.3,1.3,"Versicolor"
100+
5.1,2.5,3,1.1,"Versicolor"
101+
5.7,2.8,4.1,1.3,"Versicolor"
102+
6.3,3.3,6,2.5,"Virginica"
103+
5.8,2.7,5.1,1.9,"Virginica"
104+
7.1,3,5.9,2.1,"Virginica"
105+
6.3,2.9,5.6,1.8,"Virginica"
106+
6.5,3,5.8,2.2,"Virginica"
107+
7.6,3,6.6,2.1,"Virginica"
108+
4.9,2.5,4.5,1.7,"Virginica"
109+
7.3,2.9,6.3,1.8,"Virginica"
110+
6.7,2.5,5.8,1.8,"Virginica"
111+
7.2,3.6,6.1,2.5,"Virginica"
112+
6.5,3.2,5.1,2,"Virginica"
113+
6.4,2.7,5.3,1.9,"Virginica"
114+
6.8,3,5.5,2.1,"Virginica"
115+
5.7,2.5,5,2,"Virginica"
116+
5.8,2.8,5.1,2.4,"Virginica"
117+
6.4,3.2,5.3,2.3,"Virginica"
118+
6.5,3,5.5,1.8,"Virginica"
119+
7.7,3.8,6.7,2.2,"Virginica"
120+
7.7,2.6,6.9,2.3,"Virginica"
121+
6,2.2,5,1.5,"Virginica"
122+
6.9,3.2,5.7,2.3,"Virginica"
123+
5.6,2.8,4.9,2,"Virginica"
124+
7.7,2.8,6.7,2,"Virginica"
125+
6.3,2.7,4.9,1.8,"Virginica"
126+
6.7,3.3,5.7,2.1,"Virginica"
127+
7.2,3.2,6,1.8,"Virginica"
128+
6.2,2.8,4.8,1.8,"Virginica"
129+
6.1,3,4.9,1.8,"Virginica"
130+
6.4,2.8,5.6,2.1,"Virginica"
131+
7.2,3,5.8,1.6,"Virginica"
132+
7.4,2.8,6.1,1.9,"Virginica"
133+
7.9,3.8,6.4,2,"Virginica"
134+
6.4,2.8,5.6,2.2,"Virginica"
135+
6.3,2.8,5.1,1.5,"Virginica"
136+
6.1,2.6,5.6,1.4,"Virginica"
137+
7.7,3,6.1,2.3,"Virginica"
138+
6.3,3.4,5.6,2.4,"Virginica"
139+
6.4,3.1,5.5,1.8,"Virginica"
140+
6,3,4.8,1.8,"Virginica"
141+
6.9,3.1,5.4,2.1,"Virginica"
142+
6.7,3.1,5.6,2.4,"Virginica"
143+
6.9,3.1,5.1,2.3,"Virginica"
144+
5.8,2.7,5.1,1.9,"Virginica"
145+
6.8,3.2,5.9,2.3,"Virginica"
146+
6.7,3.3,5.7,2.5,"Virginica"
147+
6.7,3,5.2,2.3,"Virginica"
148+
6.3,2.5,5,1.9,"Virginica"
149+
6.5,3,5.2,2,"Virginica"
150+
6.2,3.4,5.4,2.3,"Virginica"
151+
5.9,3,5.1,1.8,"Virginica"

examples/document/docs/sample.pdf

805 KB
Binary file not shown.

examples/document/hello.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# import fastplotlib as fpl
2+
# import imageio.v3 as iio
3+
# import numpy as np
4+
import plotly.express as px
5+
6+
from preswald import (
7+
document,
8+
get_df,
9+
plotly,
10+
sidebar,
11+
text,
12+
)
13+
14+
15+
sidebar()
16+
17+
18+
# 2. Histogram of Sepal Length
19+
text(
20+
"## Iris Flower Classification Research Paper \n This research paper discusses the seminal work on iris flower classification, including Fisher's original 1936 paper that introduced this famous dataset for pattern recognition and machine learning."
21+
)
22+
23+
document("sample.pdf", "Original Research Paper")
24+
25+
text(
26+
"## Visualizing the Dataset Features \n Below we can see a scatter plot visualization of two key features used in iris classification: sepal length vs sepal width. The clear clustering shows why this dataset became a standard test case for machine learning algorithms."
27+
)
28+
29+
df = get_df("iris_csv")
30+
31+
fig = px.scatter(df, x="sepal.length", y="sepal.width", color="variety")
32+
33+
plotly(fig)

examples/document/images/favicon.ico

240 Bytes
Binary file not shown.

examples/document/images/logo.png

613 Bytes
Loading

examples/document/preswald.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[project]
2+
title = "Preswald Project"
3+
version = "0.1.0"
4+
port = 8501
5+
slug = "document display"
6+
entrypoint = "hello.py"
7+
8+
[branding]
9+
name = "Preswald Project"
10+
logo = "images/logo.png"
11+
favicon = "images/favicon.ico"
12+
primaryColor = "#F89613"
13+
14+
[docs.sample_pdf]
15+
type = "pdf"
16+
path = "docs/sample.pdf"
17+
18+
[data.iris_csv]
19+
type = "csv"
20+
path = "data/iris.csv"
21+
22+
[logging]
23+
level = "INFO" # Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
24+
format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"

examples/document/pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "preswald-app"
7+
version = "0.1.0"
8+
description = "A Preswald application"
9+
requires-python = ">=3.8"
10+
dependencies = [
11+
"preswald"
12+
]
13+
14+
[tool.hatch.build.targets.wheel]
15+
packages = ["."]
16+
17+
[tool.black]
18+
line-length = 88
19+
target-version = ['py38']
20+
21+
[tool.isort]
22+
profile = "black"
23+
multi_line_output = 3

examples/iris/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
secrets.toml
22
.preswald_deploy
3-
.env.structured
3+
.env.structured

examples/user_event/hello.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
# Create a scatter plot using the flattened data.
1515
# Assuming the JSON file has been flattened to include "user" and "details.clicks"
16+
print(type(df))
17+
1618
fig = px.scatter(
1719
df,
1820
x="user",

0 commit comments

Comments
 (0)