Skip to content

Add pre-commit and extended CI testing#13

Merged
CasperWA merged 17 commits intomasterfrom
cwa/close-12-pre-commit
Jan 28, 2022
Merged

Add pre-commit and extended CI testing#13
CasperWA merged 17 commits intomasterfrom
cwa/close-12-pre-commit

Conversation

@CasperWA
Copy link
Contributor

@CasperWA CasperWA commented Jan 26, 2022

Closes #12.

Update strategies with doc strings and use typing.TYPE_CHECKING.

Add README and a bit of documentation information.

Update strategies with doc strings and use TYPE_CHECKING
Add `dev` extra with development requirements.
Use Python 3.9 as minimum version.
Add checks for `project_slug` and `package_name` to pre_gen_hooks.
Use organization value in email for default.
Ensure the proper package name directory is used in `setup.py` - should
the package_name and project_slug be very different.
Add .gitignore to generated repo.

Update CI to properly run pytest in the generated repo and use a
config file for cookiecutter instead of passing arguments through the
CLI.
This script initializes the generated repository as a git repo.
It furthermore adds an initial commit that includes all the generated
files, with SINTEF as the author via the Team4.0 email.

Finally, it sets up the `origin` remote using the supplied `git_url`
input parameter and changes the branch name to `main`.
Check list of `git config` to assert whether or not git has been
configured.
@CasperWA
Copy link
Contributor Author

The pre gen hook that checks the git config, i.e., whether or not git has been configured by setting the user.name and user.email configurations works as intended as can be seen in this failing CI run (the error is intentionally raised by the pre gen hook script because it has been detected a git user is not created).

@CasperWA CasperWA changed the title Add pre-commit Add pre-commit and extended CI testing Jan 26, 2022
@CasperWA CasperWA marked this pull request as ready for review January 26, 2022 14:23
@CasperWA CasperWA requested review from kriwiik and lovfall January 26, 2022 14:23
@CasperWA CasperWA enabled auto-merge (squash) January 26, 2022 14:26
@lovfall
Copy link
Contributor

lovfall commented Jan 27, 2022

To me this looks good.

@CasperWA
Copy link
Contributor Author

To me this looks good.

Cheers. If you leave an "approving" review, I've set up the PR to be auto-merged.

@lovfall
Copy link
Contributor

lovfall commented Jan 27, 2022

To me this looks good.

Cheers. If you leave an "approving" review, I've set up the PR to be auto-merged.

@kriwiik should have the final word for this PR, that is why I left it open.

For project_slug and package_name.
But print a warning for both.
@CasperWA CasperWA requested a review from kriwiik January 27, 2022 10:55
@CasperWA CasperWA disabled auto-merge January 27, 2022 10:55
print(read_output)

return {}
read_output = download_strategy.get(session)
Copy link

Choose a reason for hiding this comment

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

This might be a stupid question, but is it necessary to use the session here? Looking at the get() functions of the download strategies in oteapi-core, I can't see that any of them use the session for anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

The session is just passed on to the download strategy in case it needs it. The session may e.g. be used to pass configurations from a filter's initialise() to a download strategy's initialise(). Not sure about the exact use case for passing the session to get(), but I think there might be similar cases for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. All strategies have the get() and initialize() methods. The get() method being the "let's do this" method...
They all take in the session dictionary, which is specific to each call and is utilized to its full intent through otelib and the pipeline system. If you are familiar with "context"-concepts in programming this is essentially that. It's a set up variables that is shared and passed along as the "context" for a single "run" through the uses of a set of strategies :)

TL;DR: Yes, the session is necessary to ensure the "context" is available for the download strategy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And for them not using the session, this will differ wildly from strategy to strategy.
I like the idea of some standard practices and usages of session however that we can think about and implement - like ensuring the local variables are always updated according to the values in the session - before falling back on default values, always check the session for that given value - etc.

Copy link

Choose a reason for hiding this comment

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

They all take in the session dictionary, which is specific to each call and is utilized to its full intent through otelib and the pipeline system. If you are familiar with "context"-concepts in programming this is essentially that. It's a set up variables that is shared and passed along as the "context" for a single "run" through the uses of a set of strategies :)

I am not familiar with "context"-concepts in programming, but I will try to read up on it + look closer at otelib to try and make sense of this.. I think I understand the point of passing the session along, but don't understand how that really happens when the functions don't use or return the session. But oh well, the PR looks good to me now and I will approve it! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's chat about it over a rundown of otelib at some point :)

@CasperWA CasperWA requested a review from kriwiik January 27, 2022 15:15
Copy link

@kriwiik kriwiik left a comment

Choose a reason for hiding this comment

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

Good job!

Copy link
Contributor

@lovfall lovfall left a comment

Choose a reason for hiding this comment

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

Looks good

@CasperWA CasperWA merged commit 40861a5 into master Jan 28, 2022
@CasperWA CasperWA deleted the cwa/close-12-pre-commit branch January 28, 2022 09:40
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.

Implement pre-commit

4 participants