Skip to content

feat: make pandas an optional dependency - #205

Open
Chaitanya A (ChaitanyaAIML-lab) wants to merge 2 commits into
microsoft:mainfrom
ChaitanyaAIML-lab:contributions/issue-199
Open

Chaitanya A (ChaitanyaAIML-lab) wants to merge 2 commits into
microsoft:mainfrom
ChaitanyaAIML-lab:contributions/issue-199

Conversation

@ChaitanyaAIML-lab

Copy link
Copy Markdown

Summary

Move pandas from required dependencies to an optional [dataframe] extra in pyproject.toml.

Core SDK surfaces (client.tables.*, client.records.*, client.query.*, client.files.*) do not require pandas. Making pandas optional removes ~30MB from the installed footprint for container and service runtimes that only require schema and basic record operations.

Fixes #199

Changes

  • pyproject.toml: Move pandas>=2.0.0 from [project.dependencies] to [project.optional-dependencies] under dataframe = ["pandas>=2.0.0"]. Add pandas to dev dependencies.
  • client.py and aio/async_client.py: Convert client.dataframe to a property that initializes DataFrameOperations on access.
  • operations/batch.py and aio/operations/async_batch.py: Convert batch.dataframe to a property that initializes BatchDataFrameOperations on access. Guard top-level pandas imports.
  • operations/dataframe.py and aio/operations/async_dataframe.py: Guard top-level pandas imports under if TYPE_CHECKING:. In __init__, raise an ImportError directing callers to install PowerPlatform-Dataverse-Client[dataframe] if pandas is not installed.
  • models/query_builder.py and models/record.py: Move top-level pandas import to if TYPE_CHECKING:, and raise an informative ImportError on to_dataframe() if pandas is missing.
  • README.md: Update installation documentation for the [dataframe] optional extra.
  • tests/unit/test_optional_pandas.py: Add unit tests covering SDK behavior with and without pandas.

Verification

  • Full test suite passed: 2431 passed, 32 subtests passed
  • New unit tests passed: 13 passed in tests/unit/test_optional_pandas.py
  • Code formatting and linting: black --check and flake8 passed with 0 errors

Move pandas to optional extra [dataframe] so the core SDK can be used in lightweight environments without installing pandas. Guard imports in client, batch, and query builder namespaces, and raise an informative ImportError suggesting the [dataframe] extra when DataFrame features are accessed without pandas installed.
Copilot AI lite review requested due to automatic review settings September 26, 2026 20:16
@ChaitanyaAIML-lab

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved review notes remain, and member assessments are mixed.

Review effort: Lite
Findings: 4 Low severity

Open (4)
What changed in this PR

Moves pandas to an optional dependency while preserving core SDK functionality without it.

Changes:

  • Adds the [dataframe] optional extra and updates installation documentation.
  • Lazily initializes synchronous and asynchronous DataFrame operations.
  • Adds informative missing-pandas errors and coverage for optional-dependency behavior.

Review notes:

  • Nit: Update both shipped SKILL.md copies with [dataframe] installation guidance.
  • Nit: Replace three # noqa presence-check suppressions with explicit dynamic imports or equivalent usage.
File Summary
tests/​unit/​test_optional_pandas.py Tests behavior with and without pandas.
src/​PowerPlatform/​Dataverse/​operations/​dataframe.py Defers pandas imports and validates availability.
src/​PowerPlatform/​Dataverse/​operations/​batch.py Lazily initializes batch DataFrame operations.
src/​PowerPlatform/​Dataverse/​models/​record.py Handles missing pandas for DataFrame conversion.
src/​PowerPlatform/​Dataverse/​models/​query_builder.py Defers pandas loading for conversion.
src/​PowerPlatform/​Dataverse/​client.py Lazily initializes sync DataFrame operations.
src/​PowerPlatform/​Dataverse/​aio/​operations/​async_dataframe.py Defers async pandas imports and validates availability.
src/​PowerPlatform/​Dataverse/​aio/​operations/​async_batch.py Lazily initializes async batch DataFrame operations.
src/​PowerPlatform/​Dataverse/​aio/​async_client.py Lazily initializes async DataFrame operations.
README.md Documents optional installation extras.
pyproject.toml Defines optional and development pandas dependencies.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md
Comment thread src/PowerPlatform/Dataverse/aio/operations/async_dataframe.py Outdated
Comment thread src/PowerPlatform/Dataverse/operations/batch.py Outdated
Comment thread src/PowerPlatform/Dataverse/operations/dataframe.py Outdated
@ChaitanyaAIML-lab

Copy link
Copy Markdown
Author

Addressed the review feedback in commit ee13111:

  1. Replaced # noqa: F401 import suppression with dynamic module imports (importlib.import_module("pandas")) in dataframe.py, async_dataframe.py, and batch.py.
  2. Updated installation instructions in both .claude/skills/dataverse-sdk-use/SKILL.md and src/PowerPlatform/Dataverse/claude_skill/dataverse-sdk-use/SKILL.md to reference the [dataframe] extra for DataFrame operations.

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.

feat: make pandas an optional dependency

2 participants