Skip to content

Commit f0073f8

Browse files
authored
connect audits (#6)
Port a couple of reports from https://solutions.posit.co/operations/connect-apis/
1 parent 14c61be commit f0073f8

File tree

16 files changed

+155
-4
lines changed

16 files changed

+155
-4
lines changed

_quarto.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
project:
22
type: website
33
render:
4-
- "**/index.qmd"
4+
- "extensions/**/connect-extension.qmd"
55
- contributing.qmd
66
- extensions.qmd
7+
- index.qmd
78

89

910
website:

contributing.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ title: Contributing
55
Add your extension in the `extensions/` subdirectory.
66
In addition to the extension code, include:
77

8-
## `index.qmd`
8+
## `connect-extension.qmd`
99

1010
A file that has the name of your extension, the categories it falls into, and a brief description
1111

12-
```{filename="index.qmd"}
12+
```{filename="connect-extension.qmd"}
1313
---
1414
title: extension title
1515
categories:

extensions.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
title: Extensions
33
listing:
44
categories: true
5-
contents: "extensions/**/index.qmd"
5+
contents: "extensions/**/connect-extension.qmd"
66
---
File renamed without changes.

extensions/audits/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
_site/

extensions/audits/_quarto.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: "Connect Audits"
6+
navbar:
7+
left:
8+
- href: index.qmd
9+
text: Home
10+
- href: unpublished.qmd
11+
text: Unpublished Content
12+
- href: runtime-versions.qmd
13+
text: Runtime Versions
14+
15+
16+
format:
17+
html:
18+
theme: cosmo
19+
css: styles.css
20+
toc: true
21+
code-fold: true
22+
23+
24+

extensions/audits/index.qmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: "Connect Audits"
3+
---
4+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-r requirements.txt
2+
ipykernel

extensions/audits/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
jupyter
2+
python-dotenv
3+
posit-sdk
4+
polars
5+
reactable
6+
great_tables
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Runtime Versions
3+
jupyter: python3
4+
---
5+
6+
```{python}
7+
import polars as pl
8+
import polars.selectors as cs
9+
import os
10+
from reactable import Reactable, Column, embed_css
11+
12+
if os.getenv("RSTUDIO_PRODUCT") != "CONNECT":
13+
from dotenv import load_dotenv
14+
load_dotenv()
15+
16+
from posit import connect
17+
client = connect.Client()
18+
19+
content = client.content.find()
20+
embed_css()
21+
```
22+
23+
24+
## Python
25+
26+
```{python}
27+
python_content = (
28+
pl.DataFrame(content, infer_schema_length=None)
29+
.filter(pl.col("py_version").is_not_null())
30+
.with_columns(
31+
pl.col("py_version")
32+
.str.split_exact(".", 3)
33+
.alias("split_version")
34+
)
35+
.with_columns([
36+
pl.col("split_version").struct.field("field_0").cast(pl.Int64).alias("major"),
37+
pl.col("split_version").struct.field("field_1").cast(pl.Int64).alias("minor"),
38+
pl.col("split_version").struct.field("field_2").cast(pl.Int64).alias("patch")
39+
])
40+
)
41+
42+
py_version_dfs = list(g for k, g in python_content.group_by("py_version"))
43+
py_summary_df = (
44+
python_content
45+
.group_by(["py_version", "major", "minor", "patch"])
46+
.agg(n=pl.len())
47+
.sort(["major", "minor", "patch"])
48+
.select(pl.col(["py_version", "n"])))
49+
50+
Reactable(
51+
py_summary_df,
52+
default_sorted=["major"],
53+
details=Column(
54+
details=lambda ri: Reactable(py_version_dfs[ri.row_index]).to_widget(),
55+
),
56+
)
57+
```
58+
59+
## R
60+
61+
```{python}
62+
r_content = (
63+
pl.DataFrame(content, infer_schema_length=None)
64+
.filter(pl.col("r_version").is_not_null())
65+
)
66+
67+
r_version_dfs = list(g for k, g in r_content.group_by("py_version"))
68+
r_summary_df = r_content.group_by("py_version").agg(n=pl.count())
69+
70+
Reactable(
71+
r_summary_df,
72+
details=Column(
73+
details=lambda ri: Reactable(r_version_dfs[ri.row_index]).to_widget(),
74+
),
75+
)
76+
```

0 commit comments

Comments
 (0)