Skip to content

fix: lazy import integrations to avoid pyspark bundling error and add deep research - #1

Merged
NormallyGaussian merged 10 commits into
mainfrom
fix/lazy-spark-imports
Jan 23, 2026
Merged

fix: lazy import integrations to avoid pyspark bundling error and add deep research#1
NormallyGaussian merged 10 commits into
mainfrom
fix/lazy-spark-imports

Conversation

@NormallyGaussian

@NormallyGaussian NormallyGaussian commented Jan 23, 2026

Copy link
Copy Markdown

Summary

Bug Fix

  • Fix CLI binary failing with No such file or directory: error-conditions.json when running parallel-cli enrich deploy --system bigquery
  • Make integrations/__init__.py use lazy imports via __getattr__ to avoid loading pyspark when not needed
  • Update PyInstaller spec to use correct integration module paths and only bundle integrations with deploy capability (bigquery, snowflake)

New Features

  • Add -o, --output option to search and extract commands to save results to a JSON file
  • Add parallel-cli research command group for deep research tasks:
    • research run - Create and run research tasks with configurable processors and polling
    • research status - Check task status by run ID
    • research poll - Resume polling existing tasks
    • research processors - List available processor tiers (pro-fast through ultra8x)

Code Quality

  • New core/research.py module with deep research API functions
  • Refactored shared polling logic to reduce code duplication
  • Added write_json_output() helper for consistent output handling
  • Added 36 new tests for research functionality with proper mocking

Test plan

  • Rebuild CLI binary with uv run python scripts/build.py --skip-deps
  • Verify parallel-cli enrich deploy --system bigquery --project=test --api-key=test no longer fails with pyspark error
  • Verify parallel-cli search --help and parallel-cli extract --help show new --output option
  • Verify parallel-cli research --help shows new research commands
  • Verify parallel-cli research processors lists all processor tiers
  • All 65 tests pass (36 new research tests + existing tests)
  • Test on other platforms via CI

The CLI binary was failing with "No such file or directory:
error-conditions.json" because pyspark was being eagerly imported
when any integration was accessed.

Changes:
- Make integrations/__init__.py use lazy imports via __getattr__
- Update PyInstaller spec to use correct integration paths
- Remove library-only integrations (polars, duckdb, spark) from bundle
- Only bundle integrations with deploy capability (bigquery, snowflake)
Add `parallel-cli research` command group for running deep research tasks:
- `research run` - Create and run research tasks with polling
- `research status` - Check task status
- `research poll` - Resume polling existing tasks
- `research processors` - List available processor tiers

Also includes:
- New core/research.py module with research API functions
- Comprehensive tests with mocking (36 tests)
- Refactored shared polling logic to reduce duplication
- Added write_json_output() helper for consistent output handling
@NormallyGaussian NormallyGaussian changed the title fix: lazy import integrations to avoid pyspark bundling error fix: lazy import integrations to avoid pyspark bundling error and add deep research Jan 23, 2026
@NormallyGaussian
NormallyGaussian marked this pull request as ready for review January 23, 2026 20:52
Add assertions after validation to narrow optional types to non-None,
fixing 10 pyrefly bad-argument-type errors in enrich_run and enrich_plan.
- Add explicit urllib.error import in auth.py
- Use SDK BetaRunInputParam type in batch.py and spark/streaming.py
- Add explicit type annotations to fix type inference issues
- Use row.asDict() for proper PySpark Row field access
- Add type narrowing assertion in test_cli.py
- Exclude non-core files from pyrefly (cloud_function, examples, notebooks, scripts)
- Add pyrefly pre-commit hook (local, uses uv run)
@NormallyGaussian
NormallyGaussian merged commit d42c19a into main Jan 23, 2026
4 checks passed
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.

2 participants