Skip to content

Commit 11148bc

Browse files
authored
chore!: Restructure folders to align with posit-dev/shinychat (#24)
1 parent c6a24a7 commit 11148bc

34 files changed

+290
-114
lines changed

.Rbuildignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/R-CMD-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ jobs:
1515
# website:
1616
# uses: rstudio/shiny-workflows/.github/workflows/website.yaml@v1
1717
# with:
18-
# working-directory: ./r-package
18+
# working-directory: ./pkg-r
1919
routine:
2020
uses: rstudio/shiny-workflows/.github/workflows/routine.yaml@v1
2121
with:
2222
format-r-code: true
23-
working-directory: ./r-package
23+
working-directory: ./pkg-r
2424
R-CMD-check:
2525
uses: rstudio/shiny-workflows/.github/workflows/R-CMD-check.yaml@v1
2626
with:
27-
working-directory: ./r-package
27+
working-directory: ./pkg-r

.github/workflows/py-release.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: Build and release Python package
1313
runs-on: ubuntu-latest
1414

15-
if: startsWith(github.ref, 'refs/tags/py-v')
15+
if: startsWith(github.ref, 'refs/tags/py/v')
1616

1717
environment:
1818
name: pypi
@@ -28,31 +28,26 @@ jobs:
2828
uses: astral-sh/setup-uv@v3
2929

3030
- name: 🐍 Set up Python ${{ env.PYTHON_VERSION }}
31-
working-directory: ./python-package
3231
run: uv python install ${{ env.PYTHON_VERSION }}
3332

3433
- name: 📦 Install the project
35-
working-directory: ./python-package
3634
run: uv sync --python ${{ env.PYTHON_VERSION }} --all-extras
3735

3836
# - name: 🧪 Check tests
39-
# working-directory: ./python-package
40-
# run: make check-tests
41-
37+
# run: make py-check-tests
4238
- name: 📝 Check types
43-
working-directory: ./python-package
44-
run: make check-types
39+
working-directory: ./pkg-py
40+
run: make py-check-types
4541

4642
- name: 📐 Check formatting
47-
working-directory: ./python-package
48-
run: make check-format
49-
43+
working-directory: ./pkg-py
44+
run: make py-check-format
5045
- name: 🧳 Build package
51-
working-directory: ./python-package
52-
run: make build
46+
working-directory: ./pkg-py
47+
run: make py-build
5348

5449
# TODO: https://pypi.org/manage/project/querychat/settings/publishing/
5550
- name: 🚢 Publish release on PyPI
5651
uses: pypa/gh-action-pypi-publish@release/v1
5752
with:
58-
packages-dir: ./python-package/dist
53+
packages-dir: ./pkg-py/dist

.github/workflows/py-test.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,16 @@ jobs:
3232
uses: astral-sh/setup-uv@v3
3333

3434
- name: 🐍 Set up Python ${{ matrix.config.python-version }}
35-
working-directory: ./python-package
3635
run: uv python install ${{matrix.config.python-version }}
3736

3837
- name: 📦 Install the project
39-
working-directory: ./python-package
40-
run: uv sync --python ${{ matrix.config.python-version }} --all-extras
38+
run: uv sync --python ${{matrix.config.python-version }} --all-extras
4139

4240
# - name: 🧪 Check tests
43-
# working-directory: ./python-package
44-
# run: make check-tests
41+
# run: make py-check-tests
4542

4643
- name: 📝 Check types
47-
# if: ${{ matrix.config.python-version != '3.9' }}
48-
working-directory: ./python-package
49-
run: make check-types
44+
run: make py-check-types
5045

5146
- name: 📐 Check formatting
52-
working-directory: ./python-package
53-
run: make check-format
47+
run: make py-check-format

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,6 @@ po/*~
244244

245245
# RStudio Connect folder
246246
rsconnect/
247+
248+
uv.lock
249+
_dev

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"python.autoComplete.extraPaths": ["${workspaceFolder}/python-package"],
2+
"python.autoComplete.extraPaths": ["${workspaceFolder}/pkg-py"],
33
"[python]": {
44
"editor.formatOnSave": true,
55
"editor.codeActionsOnSave": {

Makefile

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# Inspired by https://github.com/posit-dev/shinychat/blob/main/Makefile
2+
3+
# Use qvm to manage quarto
4+
QUARTO_VERSION ?= 1.7.31
5+
QUARTO_PATH = ~/.local/share/qvm/versions/v${QUARTO_VERSION}/bin/quarto
6+
PATH_PKG_R := pkg-r
7+
PATH_PKG_PY := pkg-py
8+
PATH_PKG_JS := js
9+
10+
# .PHONY: install-quarto
11+
# install-quarto:
12+
# @echo "🔵 Installing quarto"
13+
# @if ! [ -z $(command -v qvm)]; then \
14+
# @echo "Error: qvm is not installed. Please visit https://github.com/dpastoor/qvm/releases/ to install it." >&2 \
15+
# exit 1; \
16+
# fi
17+
# qvm install v${QUARTO_VERSION}
18+
# @echo "🔹 Updating .vscode/settings.json"
19+
# @awk -v path="${QUARTO_PATH}" '/"quarto.path":/ {gsub(/"quarto.path": ".*"/, "\"quarto.path\": \"" path "\"")} 1' .vscode/settings.json > .vscode/settings.json.tmp && mv .vscode/settings.json.tmp .vscode/settings.json
20+
# @echo "🔹 Updating .github/workflows/quartodoc.yaml"
21+
# @awk -v ver="${QUARTO_VERSION}" '/QUARTO_VERSION:/ {gsub(/QUARTO_VERSION: .*/, "QUARTO_VERSION: " ver)} 1' .github/workflows/quartodoc.yaml > .github/workflows/quartodoc.yaml.tmp && mv .github/workflows/quartodoc.yaml.tmp .github/workflows/quartodoc.yaml
22+
23+
# .PHONY: docs
24+
# docs: r-docs-render py-docs-render ## [docs] Build the documentation
25+
26+
# .PHONY: docs-preview
27+
# docs-preview: ## [docs] Preview the documentation
28+
# @npx http-server docs -p 8080
29+
30+
# .PHONY: js-setup
31+
# js-setup: ## [js] Install JS dependencies
32+
# @echo "🆙 Setup JS dependencies"
33+
# cd $(PATH_PKG_JS) && npm install
34+
35+
# .PHONY: js-setup-ci
36+
# js-setup-ci: ## [js] Install JS dependencies as CI
37+
# @echo "🆙 Setup JS dependencies"
38+
# cd $(PATH_PKG_JS) && npm ci
39+
40+
# .PHONY: js-lint
41+
# js-lint: ## [js] Lint JS code
42+
# @echo "📐 Linting JS code"
43+
# cd $(PATH_PKG_JS) && npm run lint
44+
45+
# .PHONY: js-build
46+
# js-build: ## [js] Build JS code
47+
# @echo "🧳 Building JS code"
48+
# cd $(PATH_PKG_JS) && npm run build
49+
50+
# .PHONY: js-build-watch
51+
# js-build-watch: ## [js] Build JS code in watch mode
52+
# @echo "🧳 Building JS code in watch mode"
53+
# cd $(PATH_PKG_JS) && npm run watch
54+
55+
.PHONY: r-setup
56+
r-setup: ## [r] Install R dependencies
57+
@echo "🆙 Updating R dependencies"
58+
cd $(PATH_PKG_R) && Rscript -e "pak::local_install_dev_deps()"
59+
60+
.PHONY: r-check
61+
r-check: r-check-format r-check-tests r-check-package ## [r] All R checks
62+
63+
.PHONY: r-document
64+
r-document: ## [r] Document package
65+
@echo "📜 Documenting R package"
66+
cd $(PATH_PKG_R) && Rscript -e "devtools::document()"
67+
68+
.PHONY: r-format
69+
r-format: ## [r] Format R code
70+
air format $(PATH_PKG_R)/
71+
72+
.PHONY: r-check-package
73+
r-check-package: ## [r] Check package
74+
@echo ""
75+
@echo "🔄 Running R CMD Check"
76+
cd $(PATH_PKG_R) && Rscript -e "devtools::check(document = FALSE)"
77+
78+
.PHONY: r-check-tests
79+
r-check-tests: ## [r] Check tests
80+
@echo ""
81+
@echo "🧪 Running R tests"
82+
cd $(PATH_PKG_R) && Rscript -e "devtools::test()"
83+
84+
.PHONY: r-check-format
85+
r-check-format: ## [r] Check format
86+
@echo ""
87+
@echo "📐 Checking R format"
88+
air format --check $(PATH_PKG_R)/
89+
90+
# .PHONY: r-update-dist
91+
# r-update-dist: ## [r] Update shinychat web assets
92+
# @echo ""
93+
# @echo "🔄 Updating shinychat web assets"
94+
# if [ -d $(PATH_PKG_R)/inst/lib/shiny ]; then \
95+
# rm -rf $(PATH_PKG_R)/inst/lib/shiny; \
96+
# fi
97+
# mkdir -p $(PATH_PKG_R)/inst/lib/shiny
98+
# cp -r $(PATH_PKG_JS)/dist/chat $(PATH_PKG_R)/inst/lib/shiny/
99+
# cp -r $(PATH_PKG_JS)/dist/markdown-stream $(PATH_PKG_R)/inst/lib/shiny/
100+
# (git rev-parse HEAD) > "$(PATH_PKG_R)/inst/lib/shiny/GIT_VERSION"
101+
102+
.PHONY: r-docs
103+
r-docs: ## [r] Build R docs
104+
@echo "📖 Rendering R docs with pkgdown"
105+
cd $(PATH_PKG_R) && Rscript -e "pkgdown::build_site()"
106+
107+
.PHONY: r-docs-preview
108+
r-docs-preview: ## [r] Build R docs
109+
@echo "📖 Rendering R docs with pkgdown"
110+
cd $(PATH_PKG_R) && Rscript -e "pkgdown::preview_site()"
111+
112+
.PHONY: py-setup
113+
py-setup: ## [py] Setup python environment
114+
uv sync --all-extras
115+
116+
.PHONY: py-check
117+
# py-check: py-check-format py-check-types py-check-tests ## [py] Run python checks
118+
py-check: py-check-format py-check-types ## [py] Run python checks
119+
120+
.PHONY: py-check-tox
121+
py-check-tox: ## [py] Run python 3.9 - 3.12 checks with tox
122+
@echo ""
123+
@echo "🔄 Running tests and type checking with tox for Python 3.9--3.12"
124+
uv run tox run-parallel
125+
126+
# .PHONY: py-check-tests
127+
# py-check-tests: ## [py] Run python tests
128+
# @echo ""
129+
# @echo "🧪 Running tests with pytest"
130+
# uv run playwright install
131+
# uv run pytest
132+
133+
.PHONY: py-check-types
134+
py-check-types: ## [py] Run python type checks
135+
@echo ""
136+
@echo "📝 Checking types with pyright"
137+
uv run pyright
138+
139+
.PHONY: py-check-format
140+
py-check-format:
141+
@echo ""
142+
@echo "📐 Checking format with ruff"
143+
uv run ruff check pkg-py --config pyproject.toml
144+
145+
.PHONY: py-format
146+
py-format: ## [py] Format python code
147+
uv run ruff check --fix pkg-py --config pyproject.toml
148+
uv run ruff format pkg-py --config pyproject.toml
149+
150+
# .PHONY: py-coverage
151+
# py-coverage: ## [py] Generate coverage report
152+
# @echo "📔 Generating coverage report"
153+
# uv run coverage run -m pytest
154+
# uv run coverage report
155+
156+
# .PHONY: py-coverage-report
157+
# py-coverage-report: py-coverage ## [py] Generate coverage report and open it in browser
158+
# uv run coverage html
159+
# @echo ""
160+
# @echo "📡 Serving coverage report at http://localhost:8081/"
161+
# @npx http-server htmlcov --silent -p 8081
162+
163+
# .PHONY: py-update-snaps
164+
# py-update-snaps: ## [py] Update python test snapshots
165+
# @echo "📸 Updating pytest snapshots"
166+
# uv run pytest --snapshot-update
167+
168+
# .PHONY: py-docs
169+
# py-docs: py-docs-api py-docs-render ## [py] Build python docs
170+
171+
# .PHONY: py-docs-render
172+
# py-docs-render: ## [py] Render python docs
173+
# @echo "📖 Rendering python docs with quarto"
174+
# @$(eval export IN_QUARTODOC=true)
175+
# ${QUARTO_PATH} render pkg-py/docs
176+
177+
# .PHONY: py-docs-preview
178+
# py-docs-preview: ## [py] Preview python docs
179+
# @echo "📖 Rendering python docs with quarto"
180+
# @$(eval export IN_QUARTODOC=true)
181+
# ${QUARTO_PATH} preview pkg-py/docs
182+
183+
# .PHONY: py-docs-api
184+
# py-docs-api: ## [py] Update python API docs
185+
# @echo "📖 Generating python docs with quartodoc"
186+
# @$(eval export IN_QUARTODOC=true)
187+
# cd pkg-py/docs && uv run quartodoc build
188+
# cd pkg-py/docs && uv run quartodoc interlinks
189+
190+
# .PHONY: py-docs-api-watch
191+
# py-docs-api-watch: ## [py] Update python docs
192+
# @echo "📖 Generating python docs with quartodoc"
193+
# @$(eval export IN_QUARTODOC=true)
194+
# uv run quartodoc build --config pkg-py/docs/_quarto.yml --watch
195+
196+
# .PHONY: py-docs-clean
197+
# py-docs-clean: ## [py] Clean python docs
198+
# @echo "🧹 Cleaning python docs"
199+
# rm -r pkg-py/docs/api
200+
# find pkg-py/docs/py -name '*.quarto_ipynb' -delete
201+
202+
.PHONY: py-build
203+
py-build: ## [py] Build python package
204+
@echo "🧳 Building python package"
205+
@[ -d dist ] && rm -r dist || true
206+
uv build
207+
208+
.PHONY: py-update-dist
209+
py-update-dist: ## [py] Update shinychat web assets
210+
@echo ""
211+
@echo "🔄 Updating shinychat web assets"
212+
if [ -d $(PATH_PKG_PY)/src/shinychat/www ]; then \
213+
rm -rf $(PATH_PKG_PY)/src/shinychat/www; \
214+
fi
215+
mkdir -p $(PATH_PKG_PY)/src/shinychat/www
216+
cp -r $(PATH_PKG_JS)/dist/chat $(PATH_PKG_PY)/src/shinychat/www/
217+
cp -r $(PATH_PKG_JS)/dist/markdown-stream $(PATH_PKG_PY)/src/shinychat/www/
218+
(git rev-parse HEAD) > "$(PATH_PKG_PY)/src/shinychat/www/GIT_VERSION"
219+
220+
.PHONY: help
221+
help: ## Show help messages for make targets
222+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; { \
223+
printf "\033[32m%-18s\033[0m", $$1; \
224+
if ($$2 ~ /^\[docs\]/) { \
225+
printf "\033[37m[docs]\033[0m%s\n", substr($$2, 7); \
226+
} else if ($$2 ~ /^\[py\]/) { \
227+
printf " \033[31m[py]\033[0m%s\n", substr($$2, 5); \
228+
} else if ($$2 ~ /^\[r\]/) { \
229+
printf " \033[34m[r]\033[0m%s\n", substr($$2, 4); \
230+
} else if ($$2 ~ /^\[js\]/) { \
231+
printf " \033[33m[js]\033[0m%s\n", substr($$2, 5); \
232+
} else { \
233+
printf " %s\n", $$2; \
234+
} \
235+
}'
236+
237+
.DEFAULT_GOAL := help

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
querychat is a multilingual package that allows you to chat with your data using natural language queries. It's available for:
44

5-
- [R - Shiny](r-package/README.md)
6-
- [Python - Shiny for Python](python-package/README.md)
5+
- [R - Shiny](pkg-r/README.md)
6+
- [Python - Shiny for Python](pkg-py/README.md)
77

88
## Overview
99

@@ -42,5 +42,5 @@ Currently, querychat uses DuckDB for its SQL engine. It's extremely fast and has
4242

4343
For detailed information on how to use querychat in your preferred language, see the language-specific READMEs:
4444

45-
- [R Documentation](r-package/README.md)
46-
- [Python Documentation](python-package/README.md)
45+
- [R Documentation](pkg-r/README.md)
46+
- [Python Documentation](pkg-py/README.md)
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ querychat is a drop-in component for Shiny that allows users to query a data fra
1313
## Installation
1414

1515
```bash
16-
pip install "querychat @ git+https://github.com/posit-dev/querychat#subdirectory=python-package"
16+
pip install "querychat @ git+https://github.com/posit-dev/querychat#subdirectory=pkg-py"
1717
```
1818

1919
## How to use

0 commit comments

Comments
 (0)