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

Refactor manifest writing. #465

Merged
merged 3 commits into from
Sep 13, 2021
Merged

Conversation

dblock
Copy link
Member

@dblock dblock commented Sep 13, 2021

Signed-off-by: dblock dblock@dblock.org

Description

Extracted from #461.

  • Added Manifest#to_file.
  • Refactored __to_dict__ into private methods and added a single Manifest#to_dict.
  • Added Manifest#compact that removes empty keys when writing manifests.
  • Made sure schema-version is str.

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: dblock <dblock@dblock.org>
nested = cls.compact(v)
if len(nested.keys()) > 0:
clean[k] = nested
elif v is not None and v != []:
Copy link
Member

Choose a reason for hiding this comment

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

Can be check like if not nested[k]

Copy link
Member Author

@dblock dblock Sep 13, 2021

Choose a reason for hiding this comment

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

Not sure I follow, LMK if 1664903 can be improved further.

Copy link
Member

Choose a reason for hiding this comment

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

Since we are checking whether the key has any value in the dictionary. Why not to check it like if not dict[key] which will check for value mapped to the key? Let me know what you think

Copy link
Member Author

@dblock dblock Sep 13, 2021

Choose a reason for hiding this comment

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

I don't think I understand ;) We already have a hold on v, the value through the iteration above. If that value is None or [] we don't want to write it. Why would I use d[k] here? Could you please write the function as you suggest?

Copy link
Member

@owaiskazi19 owaiskazi19 Sep 13, 2021

Choose a reason for hiding this comment

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

Ohh. I completely missed the 1664903 commit. That's exactly does what I suggested above.

Signed-off-by: dblock <dblock@dblock.org>
Signed-off-by: dblock <dblock@dblock.org>
Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

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

LGTM!

@dblock dblock merged commit a0fe3b1 into opensearch-project:main Sep 13, 2021
@dblock dblock deleted the refactor-manifests branch September 13, 2021 21:03
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.

3 participants