Skip to content

fix: resolve flake8 failures breaking the Conda workflow#323

Merged
romeokienzler merged 2 commits into
mainfrom
fix-conda-flake8-bugs
Jun 30, 2026
Merged

fix: resolve flake8 failures breaking the Conda workflow#323
romeokienzler merged 2 commits into
mainfrom
fix-conda-flake8-bugs

Conversation

@romeokienzler

Copy link
Copy Markdown
Member

Problem

The Python Package using Conda workflow fails on every push. Its flake8 hard-fail gate (--select=E9,F63,F7,F82, which stops the build on syntax errors and undefined names) flagged a mix of real bugs and template files:

operator_utils.py: F821 undefined name 'time' / 're' / 'subprocess'
fibonacci.py:       F821 undefined name 'os'
cosutils.py:        F821 undefined name 'CHUNK_SIZE'
s3_kv_store.py:     F821 undefined name 'MLX'
c3/templates/*:     E999 SyntaxError: invalid syntax  (x6)

Fixes

Real bugs (these would crash at runtime, not just lint):

  • operator_utils.pyrun_and_log() uses time, re, subprocess with no imports → add them.
  • fibonacci.py — uses os.getenv with no import os → add it.
  • cosutils.py_download() reads with an undefined CHUNK_SIZE → use the module's existing MIN_CHUNK_SIZE (8 MiB), matching _upload.
  • s3_kv_store.pymain() instantiates MLX(...) but the class is S3KVStore → fix the name.

Not a bug — false positive:

  • c3/templates/* — these are string.Template code-generation files with ${placeholder} substitutions; they are intentionally not valid standalone Python. Excluded via extend-exclude in setup.cfg [flake8] so the exclusion applies wherever flake8 runs.

Also removed two local run artifacts (experiment_logs/, iterate_study.db) that slipped in, and added them to .gitignore.

Verification

$ flake8 src terratorch_iterate --count --select=E9,F63,F7,F82
0

All four edited modules parse (AST) and operator_utils imports cleanly.

🤖 Generated with Claude Code

romeokienzler and others added 2 commits June 30, 2026 15:22
The 'Python Package using Conda' workflow's flake8 hard-fail gate
(--select=E9,F63,F7,F82) was failing on real bugs and on template files:

- operator_utils.py: run_and_log() used time, re, and subprocess without
  importing them (F821) — the function would crash at runtime. Add the
  missing imports.
- examples/fibonacci.py: used os.getenv without importing os (F821).
- util/cosutils.py: _download() read with an undefined CHUNK_SIZE (F821);
  use the module's MIN_CHUNK_SIZE constant.
- mlx/s3_kv_store.py: main() instantiated MLX(...) but the class is
  S3KVStore (F821) — fix the name.
- c3/templates/*: string.Template code-gen files with ${placeholder}
  substitutions, not valid standalone Python (E999). Exclude the
  templates dir from flake8 via setup.cfg extend-exclude.

flake8 src terratorch_iterate --select=E9,F63,F7,F82 now exits 0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Romeo Kienzler <romeo.kienzler1@ibm.com>
experiment_logs/ and iterate_study.db are local outputs from running the
iterate2 example; they should not be tracked. Remove them and add to
.gitignore.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Romeo Kienzler <romeo.kienzler1@ibm.com>
@romeokienzler romeokienzler merged commit 19d5fe1 into main Jun 30, 2026
10 checks passed
@romeokienzler romeokienzler deleted the fix-conda-flake8-bugs branch June 30, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant