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

Implement user_data from custom keyword arguments #44

Merged
merged 13 commits into from Oct 11, 2021
Merged

Conversation

aglavic
Copy link
Collaborator

@aglavic aglavic commented Sep 24, 2021

This implementation allows the users to add additional "groups" to the header by supplying keyword arguments to Orso object.

The advantage over a user_data attribute are, that the recreation from the header works directly and that it will be forward/backward compatible if we adapt a new group to the standard.
We'll have to discuss if this should be pushed upward to Header to allow user data in any block, but that might make things less clean.

@andyfaff have a look if this works as you intended.

@arm61 arm61 changed the title Implement user_data from custon keyword arguments Implement user_data from custom keyword arguments Sep 24, 2021
@andyfaff
Copy link
Contributor

Instead of making the dataclass in __new__, would it be easier to use the @dataclass decorator on the Header instead?

@aglavic on a workflow note, it might make more sense for you to fork the orsopy repository to your own GH account, and make future feature branches there. It makes the list of branches held on this repository much shorter, and removes the possibility of different users pushing to the same branch by mistake.

@aglavic
Copy link
Collaborator Author

aglavic commented Sep 27, 2021

The modifications are ready to merge, @andyfaff and @arm61, please have a look.

@andyfaff about the branches: The forking seems unnecessary extra effort on both the remote and local repository end. Isn't the point of a GIT repository to work on code together.
I don't see the issue with extra pull-request branches, as they are getting deleted after the PR is closed, right?

@andyfaff
Copy link
Contributor

Great, I'll take a look soon.

The workflow I suggested is used by other mature projects, e.g. scipy/numpy. There's still only one feature branch, it's just done on contributors forks. The workflow makes it easier for projects as they grow.

@aglavic
Copy link
Collaborator Author

aglavic commented Sep 27, 2021

OK, I can try next time. I never forked a project so I'll have to learn how the workflow is done correctly.

I think you are a bit optimistic to think that orsopy will grow to a large project with many contributors like numpy, though ;-)

@arm61
Copy link
Contributor

arm61 commented Sep 28, 2021

This looks good to me.

@arm61
Copy link
Contributor

arm61 commented Oct 1, 2021

@andyfaff shall we merge this?

@andyfaff
Copy link
Contributor

andyfaff commented Oct 1, 2021

Sorry, on leave this week, so haven't looked. I can take a look next week.

@arm61
Copy link
Contributor

arm61 commented Oct 6, 2021

@aglavic if you rebase to main the tests should pass again.

@aglavic
Copy link
Collaborator Author

aglavic commented Oct 6, 2021

@arm61 I'll wait until it's decided if this PR is accepted to avoid double effort. Although I don't understand why this branch can fail it's tests due to changes to another branch...

@arm61
Copy link
Contributor

arm61 commented Oct 6, 2021

The changes are upstream in the jsonschema package, which made a new release on the 30th September. I was having the tests fail on a branch I created that didn't make sense (cause I had only touched the documentation) so I reran the tests on this branch, which used the new version of jsonschema==4.0.1 instead of the version your tests has originally run on 3.2.0. Rebasing will pull in the pinning to this version that I implemented in #50.

@arm61 arm61 mentioned this pull request Oct 8, 2021
@aglavic
Copy link
Collaborator Author

aglavic commented Oct 8, 2021

Ah, I understand. Thanks.

Rebase didn't work out so well so I merged master into this branch.

@aglavic
Copy link
Collaborator Author

aglavic commented Oct 8, 2021

@andyfaff can you review this PR so we can close it before it diverges too far from what @arm61 is doing?

@andyfaff
Copy link
Contributor

andyfaff commented Oct 8, 2021

Yes, sorry, I was busy this week. I'll do it earlier next week.

@andyfaff
Copy link
Contributor

Looks good to me, so merging.

Perhaps we should have an pre-commit hook that auto formats our codebase with an agreed set of defaults?

@andyfaff andyfaff merged commit b091ef5 into main Oct 11, 2021
@aglavic
Copy link
Collaborator Author

aglavic commented Oct 11, 2021

@andyfaff
I think auto-formatting is fine in cases like spaces around operators etc. I'm not so sure about line breaks and continuation indents, but I won't object if you guys prefer that.

@andyfaff
Copy link
Contributor

If we use black autoformatter we can specify line length, etc. We can do it in a precommit hook to save frustration.

@arm61
Copy link
Contributor

arm61 commented Oct 11, 2021

There are benefits to having a standard style even if the style isn't to everyones preference (in particular for projects with contributors that aren't necessarily in close contact). black works for me cause it is pretty comprehensive, even if it makes things look a bit weird.

@@ -9,7 +9,9 @@
from typing import Optional, Union, List, Tuple, get_args, get_origin, Literal
import typing
from inspect import isclass
from dataclasses import field, dataclass, fields
from dataclasses import field, dataclass, fields, \
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be a complete re-implementation of all the dataclasses internal functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

The PR does implement a custom init function, which appears to be necessary to allow non-standard arguments/entries when creating the ORSO object itself.

Does this create issues for the schema generation from the codebase? Does the approach have drawbacks?

@aglavic aglavic deleted the user_data_keywords branch October 29, 2021 11:06
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.

None yet

4 participants