-
Notifications
You must be signed in to change notification settings - Fork 0
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
Initial structure and unit tests for PMR #12
Conversation
30af456
to
3ac587f
Compare
1f4f7cc
to
b440bff
Compare
This is blocked on canonical/kubeflow-ci#148. Once that is merged then we can use the action from |
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.
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.
Left some more comments, good job!
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.
LGTM! I 'm not leaving an approval
since the PMR class part is yet to be reviewed by someone more involved in that effort.
bf3a224
to
10fcd40
Compare
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.
Thanks @kimwnasptd, some comments:
- We usually keep self contained PRs that are only changing things that are related. I noticed there are a couple of things in this PR that can be grouped and pushed as their own PRs:
- Workflow changes can be split into two: PR 1 for removing the terraform integration tests, PR 2 for using the
get paths
action. - All the files that are somehow boilerplate can live in one PR (i.e.
.gitignore
,CODEOWNERS
,tox.ini
(to some extent),README
(to some extent),CONTRIBUTING
(to some extent)) - Adding the charm itself - It looks like you are approaching this repo by creating the PMR code first, then the charm, so I would suggest you avoid all charm code and metadata for now, and also avoid the template as it may introduce false positives in our tests. When you are ready to push the actual charm, then it can live in its own PR.
- PMR code - this can live in its own PR with the code's unit/integration tests, tox.ini changes, workflow changes, requirements, etc., that you need for it to work.
-
Are we using the
icon.svg
anywhere? I cannot seem to find the place where this is used. -
It's not very clear to me what is the purpose of the
ProfilesManagementRepresentation
(PMR) after looking at the code. My understanding was that a PMR is the interpretation of the data that any IdP will provide so the automator charms can convert it into actualProfile
CRs. That being said, and in the case of Github, it sounds like users are already providing the PMR and we are just running it through a schema validation to then save it in a dictionary ofProfiles
, where the keys are the name of the profile, and the values are aProfile
object.
This makes me wonder if we actually need all this machinery for just that or maybe the PMR class will make more sense when we use it with an actual IdP, but then there have to be a couple modifications:
- Considering that we'll not always have a file, potentially we'll get a list (maybe a dict) of users or groups, we'll have to change the PMR class to something that takes that as an argument in the constructor, not just a path.
- Potentially add a couple methods that can return the
Profile
(s) object so it's ready to be applied with lightkube.
@DnPlas let's use dedicated comments in the code for multiple points instead of a big one, as now we'll be having huge messages back and forth discussing many points |
I've tried to break down the functionality changes to the commit level. I'd suggest we don't go and split the PR as this would take us more time to do the review and all sub-functionalities are very small.
From what I understand, this is what's used in charmhub i.e. https://charmhub.io/kubeflow
The purpose is to define a common representation, across all IdPs/GitHub, so then we can have a common function
The logic for converting to Profiles, updating the cluster etc is now fully handled by the
In case of GH yes, the PMR should already be defined in a YAML file. So in this case the charm will
For sure once there will be another charm, that will need to convert the data to a PMR will be used more, but nevertheless the library methods (i.e.
This could be an option, so the automator charm code can initialise the PMR bottom up, by creating the classes instead of a dict. But I wouldn't rush on extending the PMR's init function yet, until we get to the other charm.
Yes, I also had this in mind! But would do this in follow-up PRs and introduce and need these changes as |
Adding some notes from today's call with @DnPlas and @mvlassis on this one:
(The PMR is essentially a thin wrapper from converting a list of Profile class instances to a dictionary, for efficient checks) |
@DnPlas thanks for the call and the review! I've pushed 2 commits that do the following:
|
4fcfa34
to
23b8e35
Compare
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.
Thanks @kimwnasptd, gave another pass.
Re: splitting Along with @mvlassis and @kimwnasptd, we decided it is okay for now to leave some of the boilerplate along the PMR changes in this PR, but in the future let's make sure to submit self-contained changes. Re: PMR and the structure We had an offline discussion and most of the conclusions are in #12 (comment) and #12 (comment) |
Regarding splitting the PR, it slipped me while reviewing. I 'm +1 that this is a very large one and normally it would be split into smaller more focused PRs. Given the point where we are though, I 'm OK this time with continuing as is. |
8fcaed9
to
f170187
Compare
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.
Thanks @kimwnasptd, good job!
c598d9e
to
c3cbda0
Compare
23b8e35
to
c3cbda0
Compare
Force pushed, since the commits were not signed. @DnPlas (or anyone from the team) could you please re-approve? NIT: I also squashed the review commits from Daniela to one |
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.
Reapproving after signing the commits, good job @kimwnasptd!
Resolves #7 1. Run `charmcraft init` 2. Strip down the charm code 3. Setup `tox` and `poetry` 1. Use `depends = poetry` in the `testenv` of tox, to ensure poetry is always installed 2. Rely only on `poetry` groups for dependencies and didn't use `depends` from `tox` 4. Update `line-length` in black to be 99 6. Create a `src/profiles_management` module 7. tox `unit`, `format`, `lint`, `integration` environments 8. Unit tests for PMR class * Takes as input * a dictionary and validate it * a file, reads it and validates it * Constructs a Python object that represents the PMR * The object provides simple access functions, like `pmr.has_profile(name)` and `profile.has_contributor(name, role)` This class is more defined in [the spec](https://docs.google.com/document/d/1WlRJTOs-J1ghZVygO3AOFvbETLyt_fY2h_PsafPMLa0/edit?tab=t.0#heading=h.ok0ig91jyc4d). ```bash sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.12 python3.12-venv -y python3.12 -m venv venv source venv/bin/activate pip install tox tox -e unit ```
Resolves #7
Changes Made
charmcraft init
tox
andpoetry
depends = poetry
in thetestenv
of tox, to ensure poetry is always installedpoetry
groups for dependencies and didn't usedepends
fromtox
line-length
in black to be 99src/profiles_management
moduleunit
,format
,lint
,integration
environmentsPMR Class
pmr.has_profile(name)
andprofile.has_contributor(name, role)
This class is more defined in the spec.
How to test