-
Notifications
You must be signed in to change notification settings - Fork 22
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
[FC-0004][RG]/edxoldmng 218/Signals to save/delete certificate configuration for a course. #158
Conversation
Thanks for the pull request, @NikolayBorovenskiy! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
@mphilbrick211: hello 😄, what should we do with the CLA issue here? |
title (int): signatory title. | ||
""" | ||
|
||
image = attr.ib(type=BinaryIO) |
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.
Can this be a URL instead (image_url
)? Signals will get translated to CloudEvent messages, which should be 64K or less. There's no guarantee that a professor's signature will fit in that limit.
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.
This is a very good question and I thought about it.
Why did I do this?
First, this is not the final version yet. What we are doing is an intermediate stage of moving towards where the configuration of certificates, the certificates themselves will be located in Credentials service.
Now the signature files are saved in MongoDB as an asset and passed to Credentials via HTTP. Also, it is passed as an ordinary multipart request where files are sent as bytes. This is the usual approach for sending files. Yes, now we use Event and look to the future, we are thinking about the future architecture, where there is a message Event Bus and events. We are doing our best to make it easy to switch to this, but for now, we are temporarily passing the certificate configuration through the HTTP API. So far, as we agreed before.
For this to be image_url
, then, when saving the configuration from Studio UI, you first need to save the file somewhere on a file system or in a cloud and pass it to the Credentials service, and this service itself will also have access to this shared storage. When we do not have Mongo DB for cert configs and signatures, and we keep this in mind, then these certificate configuration files will not be saved there and they need to be passed immediately to Credentials. Then in order for it to be image_url
, it must first be saved somewhere in intermediate public storage. But the problem is that I do not yet know what it will be and what architectural solution will be applied. This is not known. Since I wrote at the very beginning that we are at an intermediate stage of transition.
What you're talking about, where size matters is easy to solve with server-side validation, and avoid where you need to transfer a large file. Or do post-processing of the file before passing this information through the bus. But all this will be decided and a decision will be made on how to do it a little later, at the next stage, so to speak, when more becomes known and when the transfer of the certificate configuration will be completely through EvenBus, and not imitation as we are doing now. That's why for now I propose to leave it as it is, but keep in mind those solutions and problems that I described.
What do you think?
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.
My comments had two assumptions:
- Backwards compatibility concerns will require us to continue to support whatever fields are added over the long term. In order to not break plugins in the future, openedx-events opts for a pretty strict conventions around schema evolution.
- There is already a publicly accessible image URL representing the signature, since we need to display that signature to users–so we wouldn't have to save the file anywhere.
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.
Dave, I suggest we take a step back if you don't mind. I want us to be on the same page and I'm afraid to take sharp, thoughtless steps.
Since we are talking about implementation, I suggest going to this PR openedx/edx-platform#31446. This is where the implementation is. You will be able to understand what was done and how. We will approve the final decision, and then we will continue our work here.
What do you say?
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.
All right, let's just see how this goes. You can keep the BinaryIO image, but please log how large they get in the code that constructs these things so that we can examine that data after edx.org runs it.
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.
I'll do.
""" | ||
|
||
certificate_type = attr.ib(type=str) | ||
course_id = attr.ib(type=str) |
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.
In keeping with other conventions in this repo, please call this course_key
and make it of type CourseKey
.
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.
Got it.
is_active (bool): indicates whether the certifivate configuration is active. | ||
""" | ||
|
||
certificate_type = attr.ib(type=str) |
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.
In the docstring, please either enumerate the types possible, or describe where the type field data comes from and give examples.
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.
Good. I'll do it. Thank you.
COURSE_CERTIFICATE_CONFIG_DELETED = OpenEdxPublicSignal( | ||
event_type="org.openedx.content_authoring.course.certificate_config.deleted.v1", | ||
data={ | ||
"certificate_config": CertificateConfigData, |
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.
Why do we need to pass all this information if it's been deleted? Can we just pass the course_key
instead?
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.
I think we should. Why did I do this? It's all about the low coupling of the two services Studio and Credentials. We have to support it and not depend on each other. How can we efficiently delete resources in general? How do we do it with a regular http request in monolithic systems, i.e. explicitly pass an entity identifier, which is usually the primary key in a database table, or pass some unique field at the database level. Then the removal will be accurate and correct.
It’s not about our case now. Studio does not store the ID and does not know about the model from the Credentials database. It's good. course_key may or may not be a unique field. Studio doesn't know this for sure and shouldn't know. Only Credentials knows this. What can we do then when we keep services loosely coupled? Pass on as much meaningful information as possible and ask for Credentials to be removed. And Credentials itself will decide which record in the table needs to be deleted, since it is an information expert here. Which is what we do.
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.
course_key may or may not be a unique field.
But there's only ever one credentials configuration for a given course_key, right? When would we ever have more than 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.
Not certainly in that way. Look at this model please https://github.com/openedx/credentials/blob/master/credentials/apps/credentials/models.py#L194-L230
Here course_id is just a CharField and not unique. And here is our constraint unique_together = (("course_id", "certificate_type", "site")),)
which explains the behavior.
And in any case, it's not so important. After all, as I wrote above, Studio is not an information expert for Credentials and does not know the exact URI of this resource. It is important for us to maintain low coupling and sending more data will not be superfluous here.
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.
I see. I misunderstood in that I thought CertificateConfigData was the representation of all certificates for a given course (i.e. a cleaner version of the entire certificates
attribute off of the CourseBlock), rather than being the configuration for one particular certificate type for a course.
Thanks for the ping, @mariajgrimaldi! We're looking into this now, and hope to be able to push it through as soon as we can. |
8a46d50
to
559938f
Compare
Hi @NikolayBorovenskiy! When you re-run the checks, your CLA should be all set and the check should turn green. Please let me know if you have any questions. |
af232b5
to
a2025de
Compare
Hi, @mphilbrick211 looks like that CLA is good now. Thanks for pushing me. |
24264b7
to
22d4a7a
Compare
@ormsbee Dave, I've pushed all we need. Please verify this. Tnx in advance a lot. |
99877a9
to
4015419
Compare
@NikolayBorovenskiy: Please squash and fix the quality error (sort order of imports) and I'll merge. |
28ac275
to
c744de0
Compare
@ormsbee Dave, thanks a lot. I've done my part. Please do a final review and if the checkers are fine this time let's merge and make a new tag. |
@NikolayBorovenskiy 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Would you mind making a quick PR to add this to the changelog as well? |
Actually, if you could just review #180 that would be great -- let me know if that summary is correct or not. |
Description: This pr adds signals to save/delete certificate configuration for a course.
ISSUE: Link to GitHub issue
Reviewers:
Merge checklist:
Post merge:
finished.