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

Convert Python examples to proper packages #5966

Merged
merged 60 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
fca1a81
Update a few examples to python package
abey79 Apr 12, 2024
8d35203
Initial version of the `all_examples` meta-project
abey79 Apr 12, 2024
b1d97cc
[WIP] pixi support, doesn't work yet
abey79 Apr 12, 2024
5aaa970
Add python_version environment marker instead of dynamically includin…
abey79 Apr 15, 2024
ead9314
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 15, 2024
557d194
Add `exclude-platform` option to `all_examples`
abey79 Apr 15, 2024
16f050a
[TEMP] remove all_examples from pixi.toml (this breaks the lockfile)
abey79 Apr 15, 2024
6b02c31
Packagified all examples
abey79 Apr 15, 2024
5558ced
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 15, 2024
28d7fed
Some fixes
abey79 Apr 15, 2024
ae6ab12
Temporarily disable depth_guided_stable_diff to address dependency co…
abey79 Apr 15, 2024
c8a8a3d
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 15, 2024
a2a6815
Format toml
abey79 Apr 18, 2024
357ec4f
(wip) pixi.toml
abey79 Apr 18, 2024
70768c7
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 18, 2024
2644458
post merge fix
abey79 Apr 18, 2024
1fd94bd
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 18, 2024
44412db
unrolled example list in pixi.toml
abey79 Apr 18, 2024
293a7fe
Add fake rerun-sdk package to work around https://github.com/prefix-d…
abey79 Apr 19, 2024
517ca8f
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 19, 2024
1c27341
post merge
abey79 Apr 19, 2024
b45b508
Fix proto symlink
abey79 Apr 19, 2024
eb95840
Fix detect_and_track_objects.py to use legacy submodule for TrackerCSRT
abey79 Apr 19, 2024
3d7bf4c
Fix rrd/manifest building tool
abey79 Apr 19, 2024
a72bedd
Add `build-examples install` command to dev tools to install examples…
abey79 Apr 19, 2024
a60ecc7
Update CI
abey79 Apr 19, 2024
f421aa1
Update CI to pixi 0.19.1
abey79 Apr 19, 2024
8dc1581
undelete pixi.lock
abey79 Apr 19, 2024
524a0a1
bunch of cleanup & lint fix
abey79 Apr 19, 2024
0371be3
python formatting fixes
abey79 Apr 19, 2024
b754275
python typechecking fixes
abey79 Apr 19, 2024
7df1e36
toml lint
abey79 Apr 20, 2024
b5fa82b
Add cargo deny exclusion for RUSTSEC-2024-0336
abey79 Apr 20, 2024
69afcb4
Merge branch 'antoine/deny-rustls' into antoine/python-examples-2.0
abey79 Apr 20, 2024
a5ce00b
Revert "Add cargo deny exclusion for RUSTSEC-2024-0336"
abey79 Apr 20, 2024
4bb532e
update rustls to 0.21.11
abey79 Apr 20, 2024
1be29f7
Fix dead links
abey79 Apr 20, 2024
081ceb2
Merge branch 'antoine/deny-rustls' into antoine/python-examples-2.0
abey79 Apr 20, 2024
751ac43
Attempt to fix CI main
abey79 Apr 20, 2024
99a8581
update lockfile
abey79 Apr 20, 2024
12f1d93
Converted test_api to package and fixed run_python_e2e_test.py
abey79 Apr 21, 2024
91a2626
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 21, 2024
09cdb50
TEMP: disabled link checker job!!!
abey79 Apr 21, 2024
bbc3dbc
Update all example readmes
abey79 Apr 21, 2024
e8f5f6c
Update top-level example README.md
abey79 Apr 21, 2024
d98e8b5
Revert "TEMP: disabled link checker job!!!"
abey79 Apr 21, 2024
44466c9
fix lint
abey79 Apr 21, 2024
f7415d2
Update all_examples README.md
abey79 Apr 21, 2024
cb479fe
`build-examples install` now installs in editable mode
abey79 Apr 22, 2024
0d3c485
Remove dead config code and clarified `all_examples` configuration in…
abey79 Apr 22, 2024
4c8dbbd
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 22, 2024
1089726
Clarified env vars in pixi.toml
abey79 Apr 22, 2024
5f762ea
Added pixi stuff in exmaples/python/readme.md
abey79 Apr 22, 2024
cfe63cf
Lint
abey79 Apr 22, 2024
b108e58
Moar lint
abey79 Apr 22, 2024
7b8d4ba
Moar lint
abey79 Apr 22, 2024
ee908c2
:facepalm:
abey79 Apr 22, 2024
cc43d93
Merge branch 'main' into antoine/python-examples-2.0
abey79 Apr 22, 2024
632ec00
post merge
abey79 Apr 22, 2024
b73dc19
lint
abey79 Apr 22, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/auto_release_crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Update crate versions
run: pixi run python scripts/ci/crates.py version --bump prerelease
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/contrib_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Python format check
run: pixi run py-fmt-check
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Codegen check
run: pixi run codegen --force --check
Expand All @@ -114,7 +114,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Rerun lints
run: pixi run lint-rerun
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1
environments: cpp

# TODO(emilk): make this work somehow. Right now this just results in
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/contrib_rerun_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1
environments: wheel-test

- name: Build Wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on_pull_request_target_contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Update PR description
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Update crate versions
id: versioning
Expand Down Expand Up @@ -379,7 +379,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Commit new version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_build_and_upload_rerun_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Build web-viewer (release)
run: pixi run rerun-build-web-release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_build_and_upload_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Get sha
id: get-sha
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/reusable_build_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1
environments: wheel-test

- name: Download Wheel
Expand All @@ -75,9 +75,8 @@ jobs:

- name: Install example dependencies
run: |
pixi run -e wheel-test pip install \
-r scripts/ci/requirements-examples-${{ inputs.CHANNEL }}.txt \
--no-input
pixi run -e wheel-test build-examples install \
--channel ${{ inputs.CHANNEL }}

- name: Install built wheel
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_build_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Install yarn dependencies
run: pixi run yarn --cwd rerun_js install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_build_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Build web-viewer (release)
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reusable_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Codegen check
run: |
Expand All @@ -104,7 +104,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Set up Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: prettier --check
run: pixi run misc-fmt-check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_checks_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1
environments: cpp

- name: Set up Rust
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_checks_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Python format check
run: pixi run py-fmt-check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_checks_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

# We need to build the web viewer for `rust_checks.py` to succeed.
# We build in release so that we can reuse the results for actual publishing, if necessary
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Doxygen C++ docs
run: pixi run cpp-docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_publish_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Publish packages
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_publish_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1
environments: wheel-test

# built by `reusable_build_and_publish_wheels`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_publish_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- id: "auth"
uses: google-github-actions/auth@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_release_crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1

- name: Build web-viewer (release)
run: pixi run rerun-build-web-release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_run_notebook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1
environments: wheel-test

- name: Download Wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_test_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:

- uses: prefix-dev/[email protected]
with:
pixi-version: v0.19.0
pixi-version: v0.19.1
environments: wheel-test

- name: Download Wheel
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store

# Codegen stuff:
crates/re_types/source_hash.txt
crates/re_types/source_hash.txt§
crates/re_types_builder/source_hash.txt

# C++ and CMake stuff:
Expand All @@ -27,6 +27,7 @@ _deps

# Python virtual environment:
**/venv*
**/.venv*
.python-version

# Python build artifacts:
Expand Down
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
files = rerun_py/rerun_sdk/rerun, rerun_py/tests, examples/python
exclude = examples/python/objectron/proto|examples/python/ros_node
exclude = examples/python/objectron|examples/python/ros_node
namespace_packages = True
show_error_codes = True
strict = True
Expand Down
54 changes: 46 additions & 8 deletions crates/re_dev_tools/src/build_examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use anyhow::Context;
pub struct Example {
pub name: String,
pub title: String,
pub dir: PathBuf,
pub description: String,
pub tags: Vec<String>,
pub thumbnail_url: String,
Expand Down Expand Up @@ -60,21 +61,35 @@ impl Example {
else {
anyhow::bail!("example {name:?} has no frontmatter");
};
let script_path = dir.join(language.entrypoint_path(&dir, name)?);
Ok(Some(Example {
name: name.to_owned(),
title: readme.title,
dir,
description: readme.description,
tags: readme.tags,
thumbnail_url: readme.thumbnail,
thumbnail_dimensions: readme.thumbnail_dimensions,
script_path: dir.join(language.entrypoint_path()),
script_path,
script_args: readme.build_args,
readme_body: body,
language,
}))
}
}

#[derive(Debug)]
pub struct CouldNotFindEntryPoint(pub PathBuf);

impl std::error::Error for CouldNotFindEntryPoint {}

impl Display for CouldNotFindEntryPoint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("could not find entrypoint for example: ")?;
self.0.display().fmt(f)
}
}

#[derive(Clone, Copy)]
pub enum Language {
Rust,
Expand Down Expand Up @@ -112,12 +127,32 @@ impl Language {
/// For example:
/// - `main.py` for Python
/// - `src/main.rs` for Rust
pub fn entrypoint_path(&self) -> &'static Path {
pub fn entrypoint_path(
&self,
example_dir: &Path,
example_name: &str,
) -> anyhow::Result<PathBuf> {
match self {
Language::Rust => Path::new("src/main.rs"),
Language::Python => Path::new("main.py"),
Language::C => Path::new("main.c"),
Language::Cpp => Path::new("main.cpp"),
Language::Rust => Ok(PathBuf::from("src/main.rs")),
Language::Python => {
// we must handle two cases:
// - single script named after the example: `example.py`
// - package named after the example: `example/`

let mut script_path = PathBuf::from(example_name);
if example_dir.join(&script_path).exists() {
return Ok(script_path);
}

script_path.set_extension("py");
if example_dir.join(&script_path).exists() {
return Ok(script_path);
}

anyhow::bail!(CouldNotFindEntryPoint(example_dir.into()))
}
Language::C => Ok(PathBuf::from("main.c")),
Language::Cpp => Ok(PathBuf::from("main.cpp")),
}
}
}
Expand Down Expand Up @@ -168,7 +203,7 @@ pub enum Channel {
/// Examples built for each release, plus all `Main` examples.
Release,

/// Examples built nightly, plus all `Main` and `Nightly`.
/// Examples built nightly, plus all `Main` and `Release`.
Nightly,
}

Expand Down Expand Up @@ -235,14 +270,17 @@ impl Channel {
}

eprintln!("{name:?}: added");
let dir = folder.path();
let script_path = dir.join(language.entrypoint_path(&dir, &name)?);
examples.push(Example {
name,
title: readme.title,
dir,
description: readme.description,
tags: readme.tags,
thumbnail_url: readme.thumbnail,
thumbnail_dimensions: readme.thumbnail_dimensions,
script_path: folder.path().join(language.entrypoint_path()),
script_path,
script_args: readme.build_args,
readme_body: body,
language: Language::Python,
Expand Down
Loading
Loading