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

Dict memoization sorting before normalizing keys is unsafe #3157

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

MundiaNderi
Copy link

Description

Stability of sorting and transforming keys into a format suitable for sorting.

Changed Behaviour

Prior sorting was done before normalising the keys. This implementation normalises the keys and then sorts them. Added a test case that fails should this not be the case.

Fixes

Fixes #2140

Type of change

  • Bug fix

@MundiaNderi MundiaNderi changed the title Dict memoization sorting before normalizing keys is unsafe #2140 Dict memoization sorting before normalizing keys is unsafe Mar 6, 2024
@MundiaNderi
Copy link
Author

@benclifford I've worked on the memoization issue but I still have some conflicts with the max-length-files . How do I proceed ?

@benclifford
Copy link
Collaborator

You've got a lot of other random stuff in your PR that isn't related to issue #2140 - maybe you typed git add . or some command like that which added everything in your working directory?

For example, lots of test output in runinfo/ is there in your PR...

Have a look at this URL to see it all

https://github.com/Parsl/parsl/pull/3157/files

You can remove the files you don't want with git rm

It also looks like you have a few other changes with whitespace and new lines that aren't relevant to your PR.

@MundiaNderi
Copy link
Author

MundiaNderi commented Mar 6, 2024

@benclifford You're right. I used the git add command. Let me remove the files I don't want

# keys = sorted(denormalized_dict) Line that sirosen commented on
# Proposed solution was to normalize the keys and then sort them
keymap = {id_for_memo(k): k for k in denormalized_dict}
normed_keys = sorted(keymap.values())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I think this is right thing to be doing - but I don't think your test case that you added really tests that something was broken before, and is now fixed by this change.

I will try to add some comments on the test case if I can figure out a stronger test case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you , I've also realised that and was trying to think though it. Where I fell short was I corrected the implementation first, then created the test case later. I should have done vice versa.

@benclifford
Copy link
Collaborator

there are still a lot of changes in this pull request that are not directly related to the dictionary sorting issue: look in the "Files Changed" tab on this pull request in the Github web interface, and you will see a lot of unrelated changes still.

@MundiaNderi
Copy link
Author

Okay @benclifford let me work on resolving this.

@MundiaNderi
Copy link
Author

@benclifford I've cleaned up the files less one file which got messed up during rebase. How would you advise me to proceed ?

@benclifford
Copy link
Collaborator

@benclifford I've cleaned up the files less one file which got messed up during rebase. How would you advise me to proceed ?

Which file? What do you think it should look like?

@MundiaNderi
Copy link
Author

This file: parsl/dataflow/dflow.py. git rm parsl/dataflow/dflow.py deleted the file locally instead of from the commit. Ideally it should not be present within this PR but rebasing and merging .

@benclifford
Copy link
Collaborator

It looks like the change to dflow.py is a straightforward line break which you can fix by joining the lines again and making a new commit with that fix.

@MundiaNderi
Copy link
Author

Thank you @benclifford I've fixed the file.

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.

Dict memoization sorting before normalizing keys is unsafe
2 participants