Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Codebase to Use Pydantic v2 and Enhance Type Hints, Documentation #24

Merged
merged 8 commits into from
Dec 30, 2023

Conversation

greysonlalonde
Copy link
Contributor

@greysonlalonde greysonlalonde commented Dec 29, 2023

This PR primarily represents a transition from Pydantic v1 to v2. The upgrade involves the switch of Pydantic v1 imports to the newer version of Pydantic and extensive refactoring and enhancements to validators, type hints, and documentation. Below is a summary of the fundamental changes included in this PR:

Major Changes

  1. Update to Pydantic v2:

    • Transitioned all references from pydantic.v1 to pydantic (v2), ensuring compatibility with the latest Pydantic features and improvements.
    • Affected components include agent tools, prompts, crew, and task modules.
  2. Refactoring & Alignment with Pydantic Standards:

    • Refactored the agent module away from traditional __init__ to align more closely with Pydantic best practices.
    • Updated the crew module to Pydantic v2 and enhanced configurations, allowing JSON and dictionary inputs. Additionally, some (not all) exceptions have been migrated to leverage Pydantic's error-handling capabilities.
  3. Enhancements to Validators and Typings:

    • Improved validators and type annotations across multiple modules, enhancing code readability and maintainability.
    • Streamlined the validation process in line with Pydantic v2's methodologies.
  4. Import and Configuration Adjustments:

    • Updated to test-related absolute imports due to issues with Pytest finding packages through relative imports.

Minor and Housekeeping Changes

  • Removed an accidental debug commit.
  • Added JetBrains IDE-specific files (like .idea/) to .gitignore to prevent clutter.
  • Removed an unintended addition of __init__.py to root folder.

Impact

This upgrade enhances robustness, scalability, and maintainability. By adopting Pydantic v2, the codebase is now better positioned to leverage new features and improved performance. The refinements in type hinting and documentation further contribute to a more developer-friendly environment.

Refactored away from __init__ to be a little more aligned with pydantic
… pydantic v2; update validators, typings

In addition to title changes; I updated config to allow for json or dict inputs. Changed exceptions to pydantic-based
Pytest is bugging out when trying to find packages through relative imports
@greysonlalonde greysonlalonde marked this pull request as ready for review December 29, 2023 06:29
@joaomdmoura
Copy link
Collaborator

This is great! Love it, might be a complex rebase for #25, but well worth it., merging it

@joaomdmoura joaomdmoura merged commit 5cc2302 into crewAIInc:main Dec 30, 2023
@greysonlalonde
Copy link
Contributor Author

@joaomdmoura happy to help if needed! Cheers

@joaomdmoura
Copy link
Collaborator

Thanks, I'm almost done with it 💪🏼

bhancockio pushed a commit that referenced this pull request Jan 2, 2025
…ation (#24)

Update to Pydantic v2:

Transitioned all references from pydantic.v1 to pydantic (v2), ensuring compatibility with the latest Pydantic features and improvements.
Affected components include agent tools, prompts, crew, and task modules.
Refactoring & Alignment with Pydantic Standards:

Refactored the agent module away from traditional __init__ to align more closely with Pydantic best practices.
Updated the crew module to Pydantic v2 and enhanced configurations, allowing JSON and dictionary inputs. Additionally, some (not all) exceptions have been migrated to leverage Pydantic's error-handling capabilities.
Enhancements to Validators and Typings:

Improved validators and type annotations across multiple modules, enhancing code readability and maintainability.
Streamlined the validation process in line with Pydantic v2's methodologies.
Import and Configuration Adjustments:

Updated to test-related absolute imports due to issues with Pytest finding packages through relative imports.
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