Skip to content

Commit 770926b

Browse files
[SN-0] Switched notebooks to RYE for better management cleaned up everything (#1619)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent fa6deb5 commit 770926b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2090
-17116
lines changed

.github/workflows/notebooks.yml

+58-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Labelbox Python SDK Notebooks (Develop)
1+
name: Labelbox Example Notebook Workflow
22

33
on:
44
push:
@@ -13,25 +13,72 @@ on:
1313
permissions:
1414
contents: write
1515
pull-requests: write
16-
16+
1717
jobs:
18-
update:
18+
# Get installs from rye and run rye run clean to format
19+
format:
20+
if: github.event.pull_request.merged == false
1921
runs-on: ubuntu-latest
2022
steps:
2123
- uses: actions/checkout@v4
2224
with:
2325
ref: ${{ github.head_ref }}
2426
fetch-depth: 0
25-
- name: Install databooks
26-
run: pip install databooks
27-
- name: Remove notebook metadata
28-
run: echo "y" | databooks meta examples/. --rm-outs
27+
- uses: ./.github/actions/python-package-shared-setup
28+
with:
29+
rye-version: ${{ vars.RYE_VERSION }}
30+
python-version: 3.12
31+
- name: Format
32+
working-directory: examples
33+
run: rye run clean
34+
- name: Commit changes
35+
run: |
36+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
37+
git config --local user.name "github-actions[bot]"
38+
git add examples/.
39+
git commit -m ":art: Cleaned" || exit 0
40+
- name: Push changes
41+
uses: ad-m/github-push-action@master
42+
with:
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
44+
branch: ${{ github.head_ref }}
45+
# See if notebooks were added or deleted (name change counts as both)
46+
changes:
47+
needs: format
48+
if: github.event.pull_request.merged == false
49+
runs-on: ubuntu-latest
50+
outputs:
51+
addedOrModified: ${{ steps.filter.outputs.addedOrModified }}
52+
steps:
53+
- uses: dorny/paths-filter@v3
54+
id: filter
55+
with:
56+
filters: |
57+
addedOrModified:
58+
- added|deleted: 'examples/**/*.ipynb'
59+
# Create readme if the above job shows true using rye run create-readme
60+
create:
61+
needs: changes
62+
if: ${{ needs.changes.outputs.addedOrModified == 'true' }} && github.event.pull_request.merged == false
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
ref: ${{ github.head_ref }}
68+
fetch-depth: 0
69+
- uses: ./.github/actions/python-package-shared-setup
70+
with:
71+
rye-version: ${{ vars.RYE_VERSION }}
72+
python-version: 3.12
73+
- name: Create readme
74+
working-directory: examples
75+
run: rye run create-readme
2976
- name: Commit changes
3077
run: |
31-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
32-
git config --local user.name "github-actions[bot]"
33-
git add examples/.
34-
git commit -m "Removed metadata" || exit 0
78+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
79+
git config --local user.name "github-actions[bot]"
80+
git add examples/.
81+
git commit -m ":memo: README updated" || exit 0
3582
- name: Push changes
3683
uses: ad-m/github-push-action@master
3784
with:
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: ReadMe GitHub Action 🦉
2+
3+
on:
4+
pull_request:
5+
branches: [develop]
6+
types:
7+
- closed
8+
paths:
9+
- examples/README.md
10+
11+
jobs:
12+
custompages:
13+
if: github.event.pull_request.merged == true
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: ./.github/actions/python-package-shared-setup
18+
with:
19+
rye-version: ${{ vars.RYE_VERSION }}
20+
python-version: 3.12
21+
- name: Create readme
22+
working-directory: examples
23+
run: rye run create-doc-readme
24+
- name: Run `custompages` command
25+
uses: readmeio/rdme@v8
26+
with:
27+
rdme: custompages examples/tutorials.html --key=${{ secrets.README_API_KEY }}

examples/CONTRIBUTING.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Contribution Guide
2+
3+
Thank you for contributing to our notebook examples! To ensure that your contribution aligns with our guidelines, please carefully review the following guide.
4+
5+
## Table of Contents
6+
7+
- [General Notebook Requirements](#general-notebook-requirements)
8+
- [Branches and Tags](#branches-and-tags)
9+
- [Github Workflows](#github-workflows)
10+
- [General Prerequisites](#general-prerequisites)
11+
- [Styling Tools](#styling-tools)
12+
13+
## General Notebook Requirements
14+
15+
Review our [template notebook](template.ipynbs) for general overview on how notebooks should be structure. This notebook and section just serves as a guide and exceptions can be made. Here are our general requirements:
16+
17+
1. Ensure that any modified notebooks run when edited.
18+
2. Ensure that you update any relevant headers and comments within the code block you may add or change.
19+
3. Notebooks should start with a top header below the Labelbox and link icons with the title of the notebook as a main header **#** and a overview of what the notebook shows.
20+
4. Use "labelbox[data]" over labelbox for installs to ensure you have the correct dependencies.
21+
5. Imports and installs should come after the main header under a **Setup** section.
22+
6. Labelbox and other platforms with clients and API keys should be specified under a single section.
23+
7. Subsections need a second level header **##** and an overview of the section.
24+
8. The last cell should be a clean up section to delete any labelbox objects created and commented out to prevent accidentally running code blocks.
25+
9. Notebook github action [workflows](#github-workflows) are required to run successfully before merging.
26+
27+
> [!IMPORTANT]
28+
> Please make sure to remove any API keys before pushing changes
29+
30+
## Branches and Tags
31+
32+
- All development happens in feature branches ideally prefixed by contributor's initials. For example `fs/feature_name`.
33+
- Approved PRs are merged to the `develop` branch.
34+
- All releases align to a git tag.
35+
36+
## Github Workflows
37+
38+
- Github Branch Workflow
39+
- When you push to a branch that contains files inside the examples directory, it will automatically reformat your notebook to match our given style and provide appropriate headers. Once this workflow is completed it will commit back to your branch which then you can pull.
40+
- If your push contains new notebooks or modifies the names of notebooks the readme will be updated to reflect the change with updated links.
41+
42+
## General Prerequisites
43+
44+
[Rye](https://rye-up.com/) may be installed before contributing to the repository as it is the tool used to style our example notebooks. This could be used to avoid the github styling workflow. This is also the packaging tool used for the main SDK. The pyproject used for the example notebooks is a virtual package and does not get published.
45+
46+
## Styling Tools
47+
48+
Rye is setup in this directory to use a customs script that will run the notebooks through our formatting tools and create readmes.
49+
50+
- `rye sync` in the examples folder to install the correct dev dependencies.
51+
- `rye run clean` runs a series of formatting tools.
52+
- `rye run create-readme` creates a readme based off our notebooks.

examples/Makefile

-3
This file was deleted.

0 commit comments

Comments
 (0)