Skip to content

fix: Avoid deep copying in ModelContainer to resolve pickling errors#14

Open
laksi1999 wants to merge 1 commit intoveritas-toolkit:masterfrom
laksi1999:lt/add-driverlessai-support-for-veritas
Open

fix: Avoid deep copying in ModelContainer to resolve pickling errors#14
laksi1999 wants to merge 1 commit intoveritas-toolkit:masterfrom
laksi1999:lt/add-driverlessai-support-for-veritas

Conversation

@laksi1999
Copy link

@laksi1999 laksi1999 commented Jan 3, 2025

Issue

The original implementation of the ModelContainer class relied on deep copying experiment objects stored in the model_object attribute. This approach led to "cannot pickle" errors when dealing with certain objects that are not serializable, such as those from the Driverless AI. This limitation hindered users from integrating their models seamlessly, particularly when using tools that are popular in the community.

Proposed Solution

  • Introduces a new model_objects parameter, allowing users to pass pre-created model objects directly into the ModelContainer.
  • The primary change involves,
    • Eliminating the deep copying of the model_object.
    • Instead of creating a deep copy, the code now checks for the availability of a model_objects list that contains pre-created instances.
    • If this list is populated, the method pops the first object from the list and assigns it to the model_object.
  • This approach effectively resolves issues with non-picklable objects by ensuring that instances of ModelWrapper are created and passed directly, thereby avoiding serialization problems.

Note: Importantly, the existing logic for using a single model_object remains intact, allowing users to continue using the ModelContainer as they did previously without any required changes.

@laksi1999 laksi1999 changed the title feat: Add Driverless AI support for veritastool fix: Avoid deep copying in ModelContainer to resolve pickling errors Jan 3, 2025
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