-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Enabled path normalization when enable_best_effort_determinism set to… #36617
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,17 +156,24 @@ def _dumps( | |
| enable_stable_code_identifier_pickling=False, | ||
| config: cloudpickle.CloudPickleConfig = DEFAULT_CONFIG) -> bytes: | ||
|
|
||
| if enable_stable_code_identifier_pickling: | ||
| config = STABLE_CODE_IDENTIFIER_CONFIG | ||
| config_kwargs = config.__dict__.copy() | ||
|
|
||
| if enable_best_effort_determinism: | ||
| # TODO: Add support once https://github.com/cloudpipe/cloudpickle/pull/563 | ||
| # is merged in. | ||
| _LOGGER.warning( | ||
| 'Ignoring unsupported option: enable_best_effort_determinism. ' | ||
| 'This has only been implemented for dill.') | ||
| config_kwargs['filepath_interceptor'] = cloudpickle.get_relative_path | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rather explicitly define a BEST_EFFORT_DETERMINISM config at the top of this file and use that? Its easier to see exact settings BEST_EFFORT_DETERMINISM requires and no copying configs required |
||
| _LOGGER.info( | ||
| 'Option not fully supported:' | ||
| 'enable_best_effort_determinism is True: Applying file path ' | ||
| 'normalization for pickling.' | ||
| 'This has been fully implemented for dill.') | ||
|
|
||
| final_config = cloudpickle.CloudPickleConfig(**config_kwargs) | ||
| with _pickle_lock: | ||
| with io.BytesIO() as file: | ||
| if enable_stable_code_identifier_pickling: | ||
| config = STABLE_CODE_IDENTIFIER_CONFIG | ||
| pickler = cloudpickle.CloudPickler(file, config=config) | ||
| pickler = cloudpickle.CloudPickler(file, config=final_config) | ||
| try: | ||
| pickler.dispatch_table[type(flags.FLAGS)] = _pickle_absl_flags | ||
| except NameError: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| """A test module for source file path normalization.""" | ||
|
|
||
|
|
||
| def func_for_path_test(): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you define this in cloudpickle_pickler_test instead of creating a new file? |
||
| """A simple function for path normalization testing.""" | ||
| return "hello" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused about the difference between these options.
Is enable_best_effort_determinism meant to include the stable identifier change too? Or is that not part of best effort determinisn?