Skip to content

Commit a2410ff

Browse files
strickvlClaudeCopilot
authored
Add CI checks for formatting + clean up CI (#217)
* Format files with latest ruff * Add .claude/ to gitignore 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Fix unused variables and add notebook exclusion to format script - Fix unused variables across multiple Python files - Fix syntax error in zencoder/test_starcoder_bigcode.py - Exclude Jupyter notebooks from linting checks in format.sh 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * remove unused CI workflows * Add code formatting CI workflow - Created new GitHub Actions workflow 'code-formatting.yml' that runs the formatting script - Workflow checks if code meets formatting standards and fails if any changes are needed - Updated pull_request.yml to include the new formatting check - Ensures PRs cannot be merged until code passes formatting checks * Fix workflow_call trigger in code-formatting.yml * Update llm-complete-guide/utils/llm_utils.py Co-authored-by: Copilot <[email protected]> * Update magic-photobooth/frontend.py Co-authored-by: Copilot <[email protected]> * small redundancy fix * Update CI to install latest ruff version and display version in logs * Update README and CONTRIBUTING.md with formatting requirements * Update CI * Formatting --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 2b54d42 commit a2410ff

34 files changed

+318
-277
lines changed

.github/workflows/code-formatting.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Code Formatting
2+
3+
on:
4+
workflow_call:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
formatting-check:
11+
name: Code Formatting Check
12+
runs-on: ubuntu-latest
13+
if: github.event.pull_request.draft == false
14+
env:
15+
ZENML_DEBUG: 1
16+
ZENML_ANALYTICS_OPT_IN: false
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.9'
25+
26+
- name: Install latest ruff
27+
run: pip install --upgrade ruff
28+
29+
- name: Run formatting script
30+
run: bash scripts/format.sh
31+
32+
- name: Check for changes
33+
id: git-check
34+
run: |
35+
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
36+
37+
- name: Fail if changes were made
38+
if: steps.git-check.outputs.changes == 'true'
39+
run: |
40+
echo "::error::Formatting check failed. Please run 'scripts/format.sh' locally and commit the changes."
41+
exit 1

.github/workflows/gpt4_summarizer.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/production_run_complete_llm.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/pull_request.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Spell Checking
1+
name: Pull Request Checks
22

33
on:
44
pull_request:
@@ -25,3 +25,11 @@ jobs:
2525
markdown-link-check:
2626
uses: ./.github/workflows/markdown-link-check.yml
2727
if: github.event.pull_request.draft == false
28+
29+
code-formatting-check:
30+
uses: ./.github/workflows/code-formatting.yml
31+
if: github.event.pull_request.draft == false
32+
33+
readme-projects-check:
34+
uses: ./.github/workflows/readme-projects-check.yml
35+
if: github.event.pull_request.draft == false
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: README Projects Check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
readme-projects-check:
8+
name: Check Projects in README
9+
runs-on: ubuntu-latest
10+
if: github.event.pull_request.draft == false
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.9'
19+
20+
- name: Run README projects check
21+
run: python3 scripts/check_readme_projects.py

.github/workflows/staging_run_complete_llm.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,6 @@ finetuned-snowflake-arctic-embed-m-v1.5/
167167

168168
# ollama ignores
169169
nohup.out
170+
171+
# Claude
172+
.claude/

CONTRIBUTING.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,23 @@ the ["fork-and-pull" Git workflow](https://github.com/susam/gitpr)
9999
4. Checkout the **main** branch <- `git checkout main`.
100100
5. Create a branch locally off the **main** branch with a succinct but descriptive name.
101101
6. Commit changes to the branch.
102-
7. Push changes to your fork.
103-
8. Open a PR in our repository to the `main` branch and
102+
7. Format your code by running `bash scripts/format.sh` before committing.
103+
8. Push changes to your fork.
104+
9. Open a PR in our repository to the `main` branch and
104105
follow the PR template so that we can efficiently review the changes.
105106

107+
#### Code Formatting
108+
109+
All code must pass our formatting checks before it can be merged. We use [ruff](https://github.com/astral-sh/ruff) for code formatting and linting.
110+
111+
To format your code locally:
112+
```bash
113+
# Run from the project root
114+
bash scripts/format.sh
115+
```
116+
117+
Our CI pipeline automatically checks if your code is properly formatted. If the check fails, you'll need to run the formatting script locally and commit the changes before your PR can be merged.
118+
106119
### 🚨 Reporting a Vulnerability
107120

108121
If you think you have found a vulnerability, and even if you are not sure about it,

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ installation details.
8888
We welcome contributions from anyone to showcase your project built using ZenML.
8989
See our [contributing guide](./CONTRIBUTING.md) to start.
9090

91+
## Code Quality
92+
93+
All code contributions must pass our automated code quality checks:
94+
- **Code Formatting**: We use [ruff](https://github.com/astral-sh/ruff) for code formatting and linting
95+
- **Spelling**: We check for typos and spelling errors
96+
- **Markdown Links**: We verify that all links in documentation work properly
97+
98+
Our CI pipeline will automatically check your PR for these issues. Remember to run `bash scripts/format.sh` locally before submitting your PR to ensure it passes the formatting checks.
99+
91100
# 🆘 Getting Help
92101

93102
By far the easiest and fastest way to get help is to:

databricks-production-qa-demo/steps/deployment/deployment_deploy.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@
3131

3232

3333
@step(enable_cache=False)
34-
def deployment_deploy() -> (
35-
Annotated[
36-
Optional[DatabricksDeploymentService],
37-
ArtifactConfig(
38-
name="databricks_deployment", is_deployment_artifact=True
39-
),
40-
]
41-
):
34+
def deployment_deploy() -> Annotated[
35+
Optional[DatabricksDeploymentService],
36+
ArtifactConfig(name="databricks_deployment", is_deployment_artifact=True),
37+
]:
4238
"""Predictions step.
4339
4440
This is an example of a predictions step that takes the data in and returns

gamesense/steps/log_metadata.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# limitations under the License.
1616
#
1717

18-
from typing import Any, Dict
1918

2019
from zenml import get_step_context, log_metadata, step
2120

@@ -33,9 +32,8 @@ def log_metadata_from_step_artifact(
3332
"""
3433

3534
context = get_step_context()
36-
metadata_dict: Dict[str, Any] = context.pipeline_run.steps[
37-
step_name
38-
].outputs[artifact_name]
35+
# Access the artifact metadata but don't store the unused variable
36+
_ = context.pipeline_run.steps[step_name].outputs[artifact_name]
3937

4038
log_metadata(
4139
artifact_name=artifact_name,

huggingface-sagemaker/steps/deploying/huggingface_deployment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def deploy_to_huggingface(
4747
save_model_to_deploy.entrypoint()
4848

4949
logger.info("Model saved locally. Pushing to HuggingFace...")
50-
assert secret, "No secret found with name 'huggingface_creds'. Please create one with your `token`."
50+
assert secret, (
51+
"No secret found with name 'huggingface_creds'. Please create one with your `token`."
52+
)
5153

5254
token = secret.secret_values["token"]
5355
api = HfApi(token=token)

huggingface-sagemaker/steps/promotion/promote_get_metrics.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727

2828

2929
@step
30-
def promote_get_metrics() -> (
31-
Tuple[
32-
Annotated[Dict[str, Any], "latest_metrics"],
33-
Annotated[Dict[str, Any], "current_metrics"],
34-
]
35-
):
30+
def promote_get_metrics() -> Tuple[
31+
Annotated[Dict[str, Any], "latest_metrics"],
32+
Annotated[Dict[str, Any], "current_metrics"],
33+
]:
3634
"""Get metrics for comparison for promoting a model.
3735
3836
This is an example of a metric retrieval step. It is used to retrieve

llm-complete-guide/steps/eval_retrieval.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ def perform_small_retrieval_evaluation(use_reranking: bool) -> float:
275275

276276

277277
@step
278-
def retrieval_evaluation_small() -> (
279-
Annotated[float, "small_failure_rate_retrieval"]
280-
):
278+
def retrieval_evaluation_small() -> Annotated[
279+
float, "small_failure_rate_retrieval"
280+
]:
281281
"""Executes the retrieval evaluation step without reranking.
282282
283283
Returns:
@@ -287,9 +287,9 @@ def retrieval_evaluation_small() -> (
287287

288288

289289
@step
290-
def retrieval_evaluation_small_with_reranking() -> (
291-
Annotated[float, "small_failure_rate_retrieval_reranking"]
292-
):
290+
def retrieval_evaluation_small_with_reranking() -> Annotated[
291+
float, "small_failure_rate_retrieval_reranking"
292+
]:
293293
"""Executes the retrieval evaluation step with reranking.
294294
295295
Returns:

0 commit comments

Comments
 (0)