Skip to content

Commit 32891c6

Browse files
Improve Makefile documentation and add caching for notebooks repository (#150)
- Use shorter commit hash (7 chars) in frontend/COMMIT for consistency - Add consistent annotations across all Makefiles about kubeflow/notebooks repo - Add intelligent caching to frontend Makefile setup: * Skip git fetch/checkout if already at target commit * Skip library rebuild if already built * Skip npm install if dependencies exist * Skip symlink recreation if already correct * Skip asset copying if already present - Add automatic CSS and assets copying during setup - Add fallback for short hash resolution with git rev-parse Resolves issues with fresh setup and improves developer experience with faster repeated setup runs. --------- Signed-off-by: Harshit Nayan <harshitacademia@gmail.com> Signed-off-by: Julius von Kohout <45896133+juliusvonkohout@users.noreply.github.com> Co-authored-by: Julius von Kohout <45896133+juliusvonkohout@users.noreply.github.com>
1 parent 368e998 commit 32891c6

6 files changed

Lines changed: 55 additions & 23 deletions

File tree

.github/workflows/linting_bash_python_yaml_files.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
fetch-depth: 0
4040

4141
- name: Install yamllint
42-
run: python3 -m venv myenv && source myenv/bin/activate && pip install yamllint
42+
run: pip install yamllint
4343

4444
- name: YAML Formatting Guidelines
4545
run: |
@@ -88,7 +88,6 @@ jobs:
8888
- name: Run yamllint on changed files
8989
id: lint
9090
run: |
91-
source myenv/bin/activate
9291
if grep -q 'No YAML files have changed in this PR.' changed_files_in_PR.txt; then
9392
echo "No YAML files have changed in this PR."
9493
else
@@ -132,7 +131,7 @@ jobs:
132131
fi
133132
134133
- name: Display changed files
135-
if: always() # Always run this step
134+
if: always() # Always run this step
136135
run: cat changed_files_in_PR.txt || echo "No bash files have changed in this PR."
137136

138137
- name: Run ShellCheck on changed files

.github/workflows/stale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: Mark stale issues and pull requests
77

88
on:
99
schedule:
10-
- cron: '0 0 * * *' # Run every day at midnight
10+
- cron: '0 0 * * *' # Run every day at midnight
1111
workflow_dispatch:
1212

1313
jobs:

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Local path to kubeflow/notebooks repo for common backend code.
2+
# Clone https://github.com/kubeflow/notebooks to develop locally.
3+
# Set KUBEFLOW_REPOSITORY env var or use default /tmp/notebooks.
4+
KUBEFLOW_REPOSITORY ?= /tmp/notebooks
5+
16
# Default to kserve if not specified, but allow override via environment variable
27
GITHUB_REPOSITORY_OWNER ?= kserve
38
IMG ?= ghcr.io/$(shell echo $(GITHUB_REPOSITORY_OWNER) | tr '[:upper:]' '[:lower:]')/models-web-app

backend/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
SHELL=bash
22

3-
# In order to develop locally you will need to use common python code
4-
# from the kubeflow/notebooks repo. You can clone the repo in a specific
5-
# folder and use the following ENV Var to configure it.
3+
# Local path to kubeflow/notebooks repository for common backend code.
4+
# Clone https://github.com/kubeflow/notebooks to develop locally.
5+
# Set KUBEFLOW_REPOSITORY environment variable or use the default /tmp/notebooks.
66
KUBEFLOW_REPO ?= $(or $(KUBEFLOW_REPOSITORY),/tmp/notebooks)
77
COMMON_BACKEND_DIR ?= ${KUBEFLOW_REPO}/components/crud-web-apps/common/backend
88

frontend/COMMIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0b835a7848ddcadf2c920a8e14aeae121ac982d9
1+
0b835a7

frontend/Makefile

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
# make setup KUBEFLOW_REPOSITORY=/path/to/kubeflow
55
# make setup KF_REPO=/path/to/kubeflow
66

7-
KUBEFLOW_REPOSITORY ?= $(or $(KF_REPO),../../notebooks)
7+
# Local path to kubeflow/notebooks repoSITORY for THE common frontend library.
8+
# Clone https://github.com/kubeflow/notebooks to develop locally.
9+
# Set KUBEFLOW_REPOSITORY ennvironment variable, or use the default ../../notebooks.
10+
KUBEFLOW_REPOSITORY ?= $(../../notebooks)
811
KUBEFLOW_REMOTE ?= https://github.com/kubeflow/notebooks
912

1013
COMMIT_FILE := ./COMMIT
@@ -22,25 +25,50 @@ setup:
2225
echo "Cloning $(KUBEFLOW_REMOTE) into $(KUBEFLOW_REPOSITORY)"; \
2326
git clone "$(KUBEFLOW_REMOTE)" "$(KUBEFLOW_REPOSITORY)"; \
2427
fi
25-
@echo ">> Checking repository status"
2628
@TARGET_COMMIT=$$(cat "$(COMMIT_FILE)"); \
27-
cd "$(KUBEFLOW_REPOSITORY)" && \
28-
git fetch "$(KUBEFLOW_REMOTE)" notebooks-v1 && \
29-
git checkout "$$TARGET_COMMIT"
29+
CURRENT_COMMIT=$$(cd "$(KUBEFLOW_REPOSITORY)" 2>/dev/null && git rev-parse --short=8 HEAD 2>/dev/null || echo ""); \
30+
if [ "$$CURRENT_COMMIT" != "$$TARGET_COMMIT" ]; then \
31+
echo ">> Checking out target commit $$TARGET_COMMIT"; \
32+
cd "$(KUBEFLOW_REPOSITORY)" && \
33+
git fetch "$(KUBEFLOW_REMOTE)" notebooks-v1 && \
34+
git checkout "$$TARGET_COMMIT" || git checkout "$$(git rev-parse $$TARGET_COMMIT)"; \
35+
else \
36+
echo ">> Already at target commit $$TARGET_COMMIT"; \
37+
fi
3038
@if [ ! -d "$(COMMON_LIBRARY_DIRECTORY)" ]; then \
31-
echo "Expected common lib at: $(COMMON_LIBRARY_DIRECTORY)"; \
39+
echo "Expected common library at: $(COMMON_LIBRARY_DIRECTORY)"; \
3240
echo "Verify KUBEFLOW_REPOSITORY is correct."; \
3341
exit 1; \
3442
fi
35-
@echo ">> Building kubeflow-common-library"
36-
@cd "$(COMMON_LIBRARY_DIRECTORY)" && \
37-
npm install && \
38-
npm run build
39-
@echo ">> Installing frontend dependencies and linking kubeflow-common-library"
40-
@npm install
41-
@rm -rf node_modules/kubeflow
42-
@ln -s "$$(readlink -f $(COMMON_LIBRARY_DISTRIBUTION))" node_modules/kubeflow
43-
@echo "✔ Setup complete. Now run: npm run build:watch"
43+
@if [ ! -d "$(COMMON_LIBRARY_DISTRIBUTION)" ]; then \
44+
echo ">> Building kubeflow-common-library"; \
45+
cd "$(COMMON_LIBRARY_DIRECTORY)" && \
46+
npm install && \
47+
npm run build; \
48+
else \
49+
echo ">> Kubeflow library already built"; \
50+
fi
51+
@if [ ! -d "node_modules" ]; then \
52+
echo ">> Installing frontend dependencies"; \
53+
npm install; \
54+
else \
55+
echo ">> Frontend dependencies already installed"; \
56+
fi
57+
@if [ ! -L "node_modules/kubeflow" ] || [ "$$(readlink node_modules/kubeflow)" != "$$(readlink -f $(COMMON_LIBRARY_DISTRIBUTION))" ]; then \
58+
echo ">> Linking kubeflow-common-library"; \
59+
rm -rf node_modules/kubeflow; \
60+
ln -s "$$(readlink -f $(COMMON_LIBRARY_DISTRIBUTION))" node_modules/kubeflow; \
61+
else \
62+
echo ">> Kubeflow library already linked"; \
63+
fi
64+
@if [ ! -d "src/styles" ] || [ ! -d "src/assets" ]; then \
65+
echo ">> Copying kubeflow styles and assets"; \
66+
npm run copyCSS; \
67+
npm run copyLibAssets; \
68+
else \
69+
echo ">> Styles and assets already copied"; \
70+
fi
71+
@echo "✔ Setup complete. Now run: npm run serve:simple or npm run build:watch"
4472

4573
clean:
4674
@echo ">> Cleaning frontend node_modules"

0 commit comments

Comments
 (0)