Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was changed
temporalio.worfklow.SandboxImportNotificationPolicyenum.SandboxRestrictions.import_notification_policysetting to control the notification policy for imports processed by the sandbox.workflow.unsafeto allow overriding theSandboxImportNotificationPolicyset on the configuredSandboxRestritions.RestrictionContext.in_activationfield to indicate if the sandbox is handling an activation so we can differentiate between workflow load time._Importerto respect the override and configured policy to:SandboxRestrictions.defaultto useSandboxImportNotificationPolicy.WARN_ON_DYNAMIC_IMPORTSandboxImportNotificationPolicyflags toSandboxRestrictionsfor ease of use.Why?
The introduction of the new import notification policy aims to tackle two challenges SDK users face that are described in #790. The new behaviors can be combined to provide the desired level of verbosity.
Increase Visibility into Dynamically Imported Modules
Some libraries will import modules as needed or as a result of a function call. In these cases, it may not be obvious to users that this is occurring and can cause unnecessary memory overhead. This new default setting will warn any time an import occurs during workflow task execution. Users may opt out of this warning by configuring the
SandboxRunnerwith aSandboxImportNotificationPolicyor by using the context managerworkflow.unsafe.sandbox_import_notification_policy.Increase Discoverability of Modules Requiring Passthrough
Some users prefer to ensure that imports used by the sandbox are explicitly passed through. The new opt-in settings of
SandboxImportNotificationPolicy.WARN_ON_UNINTENTIONAL_PASSTHROUGHandSandboxImportNotificationPolicy.RAISE_ON_UNINTENTIONAL_PASSTHROUGHallow users to discover any import that occurs in the sandbox that is not explicitly passed through. These settings are mutually exclusive and if both are set on the import notification policy,RAISE_ON_UNINTENTIONAL_PASSTHROUGHwill be respected. Users may opt into this behavior by configuring theSandboxRunnerwith aSandboxImportNotificationPolicyor by using the context managerworkflow.unsafe.sandbox_import_notification_policy.Checklist
Closes #790
How was this tested:
New tests were added to exercise a variety of policy combinations and verify that code run in an interceptor will also respect the new setting.
Any docs updates needed?