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

SPARKNLP-797: Introduce Protected Features #13777

Conversation

DevinTDHa
Copy link
Member

Description

This PR adds the functionality of Feature class parameters to be protected. This means, that the Feature can only be set once during the initialization process (for example loadSavedModel). Subsequent attempts to set it will result in an exception. The reason is, that some parameters of pretrained models should not be set after they have been loaded.

The following Feature parameters have been set to be protected:

  • vocabulary
  • merges
  • signatures
  • labels

Motivation and Context

Not letting the user set these parameters will result in less unintended behavior.

How Has This Been Tested?

Added new tests to verify the new behavior.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Code improvements with no or little impact
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING page.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

- Added setProtected method for annotator features, so that they are only settable once
- Added test to verify this behavior
@DevinTDHa DevinTDHa requested a review from maziyarpanahi May 1, 2023 15:27
@DevinTDHa DevinTDHa added enhancement DON'T MERGE Do not merge this PR labels May 1, 2023
@maziyarpanahi maziyarpanahi changed the base branch from master to release/442-release-candidate May 10, 2023 09:48
- let's not throw hard exception in the minor release - will log this later for clarity of the users
@maziyarpanahi maziyarpanahi merged commit 76432d4 into JohnSnowLabs:release/442-release-candidate May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DON'T MERGE Do not merge this PR enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants