fix: CLI bugs in build, push commands and init templates#377
fix: CLI bugs in build, push commands and init templates#377zamalali wants to merge 6 commits intometa-pytorch:mainfrom
Conversation
|
Hi @zamalali! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Greptile OverviewGreptile SummaryThis PR fixes 6 legitimate bugs across CLI commands and init templates that were introduced after the async-first EnvClient migration. All fixes are minimal and well-tested. Key Changes:
Test Coverage:
Issue Found:
Confidence Score: 4/5
Important Files Changed
|
| @@ -1,4 +1,4 @@ | |||
| openenv[core]>=0.2.0 | |||
| openenv-core[core]>=0.2.1 | |||
There was a problem hiding this comment.
version mismatch: pyproject.toml shows version = "0.2.0" but template requires >=0.2.1
| openenv-core[core]>=0.2.1 | |
| openenv-core[core]>=0.2.0 |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/openenv/cli/templates/openenv_env/server/requirements.txt
Line: 1:1
Comment:
version mismatch: `pyproject.toml` shows `version = "0.2.0"` but template requires `>=0.2.1`
```suggestion
openenv-core[core]>=0.2.0
```
How can I resolve this? If you propose a fix, please make it concise.073d383 to
9bd5d6f
Compare
Fix 6 bugs across CLI commands and scaffolding templates:
build.py:
- Use stdlib tomllib (3.11+) with tomli fallback at module level,
replacing 2 inline 'import tomli' calls that crashed without tomli
- Remove duplicate rel_str.startswith("envs/") condition (copy-paste bug)
push.py:
- Remove file=sys.stderr kwarg from console.print() (Rich Console
does not accept file; this raised TypeError at runtime)
- Remove dead variable _in_frontmatter (assigned but never read);
add break to exit loop after first frontmatter closing ---
- Remove now-unused import sys
templates (openenv init scaffolding):
- Fix client.py docstring: bare with context manager crashes because
EnvClient.__enter__ raises TypeError; show async with (recommended)
and .sync() wrapper examples instead
- Fix README.md: update Using the Context Manager and Concurrent
WebSocket Sessions sections to use async with / asyncio.gather
instead of bare with / ThreadPoolExecutor
- Fix server/requirements.txt: openenv[core] to openenv-core[core]
and >=0.2.0 to >=0.2.1 to match pyproject.toml package name
Tests:
- Update test_init_requirements_file assertion to match new package name
- Add test_push_rejects_interface_and_no_interface test
Summary
After the async-first EnvClient migration, several CLI commands and the
openenv inittemplates were left with broken code paths. This PR fixes 6 bugs acrossbuild.py,push.py, and the init scaffolding templates. All fixes are minimal, no behavior changes for working code paths, no new dependencies, no breaking changes.Type of Change
What's Fixed
build.py
tomli import crashes on Python 3.11+: Two functions did
import tomliinline with a silentexcept ImportErrorfallback that skipped TOML parsing entirely. On Python 3.11+ wheretomllibis in stdlib andtomlimay not be installed, this silently skipped dependency checking. Moved to a module-leveltry: import tomllib / except: import tomli as tomllib, matching the pattern already used in_validation.py.Duplicate condition:
rel_str.startswith("envs/")appeared twice in the sameifstatement. Removed the duplicate.push.py
Rich Console TypeError:
console.print(..., file=sys.stderr)blows up at runtime because Rich'sConsole.print()does not accept afile=kwarg. This crashes the--interface --no-interfaceconflict check. Removed thefile=sys.stderrargument to match every other error path in the same file.Dead variable + missing break:
_in_frontmatterwas assigned but never read. The loop also kept iterating past the first frontmatter closing---. Removed the dead variable and addedbreak. Also removed the now-unusedimport sys.Templates (openenv init scaffolding)
Bare
within docstring and README crashes:EnvClient.__enter__raisesTypeErrordirecting users to useasync withor.sync(). Butclient.pydocstring andREADME.mdcode examples still showed barewith Env(...). Updated both to showasync with(recommended) and.sync()wrapper, consistent with the project README and all documentation.Wrong package name in requirements.txt: Template had
openenv[core]>=0.2.0but the actual PyPI package isopenenv-core(with a hyphen), and the current version is0.2.1. Changed toopenenv-core[core]>=0.2.1to matchpyproject.toml.RFC Status
Test Plan
test_init_requirements_fileto assert the corrected package nametest_push_rejects_interface_and_no_interfacecovering the fixed error path (no mocking needed since the flag check runs before any HF API calls)ruff checkandruff format --checkpass on entiresrc/andtests/