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

[FC-0004][RG]/edxoldmng 218/Signals to save/delete certificate configuration for a course. #158

Conversation

NikolayBorovenskiy
Copy link
Contributor

Description: This pr adds signals to save/delete certificate configuration for a course.

ISSUE: Link to GitHub issue

Reviewers:

Merge checklist:

  • All reviewers approved
  • CI build is green
  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Commits are squashed

Post merge:

  • Create a tag
  • Check new version is pushed to PyPI after tag-triggered build is
    finished.
  • Delete working branch (if not needed anymore)

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 14, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Dec 14, 2022

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:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

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.

@NikolayBorovenskiy NikolayBorovenskiy changed the title [RG]/edxoldmng 218/Signals to save/delete certificate configuration for a course. [FC-0004][RG]/edxoldmng 218/Signals to save/delete certificate configuration for a course. Dec 14, 2022
@mariajgrimaldi
Copy link
Member

@mphilbrick211: hello 😄, what should we do with the CLA issue here?

title (int): signatory title.
"""

image = attr.ib(type=BinaryIO)
Copy link

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.

Copy link
Contributor Author

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?

Copy link

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:

  1. 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.
  2. 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.

Copy link
Contributor Author

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?

Copy link

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.

Copy link
Contributor Author

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)
Copy link

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.

Copy link
Contributor Author

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)
Copy link

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.

Copy link
Contributor Author

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,
Copy link

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?

Copy link
Contributor Author

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.

Copy link

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?

Copy link
Contributor Author

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.

Copy link

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.

@mphilbrick211
Copy link

@mphilbrick211: hello 😄, what should we do with the CLA issue here?

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.

@NikolayBorovenskiy NikolayBorovenskiy force-pushed the nborovesnkiy/EDXOLDMNG-218/copy-certificate-configurations-including-signatures-to-credentials-on-certificate-update branch from 8a46d50 to 559938f Compare December 26, 2022 17:31
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Dec 27, 2022
@e0d e0d removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Jan 5, 2023
@mphilbrick211
Copy link

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.

@mphilbrick211 mphilbrick211 added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Jan 6, 2023
@NikolayBorovenskiy NikolayBorovenskiy force-pushed the nborovesnkiy/EDXOLDMNG-218/copy-certificate-configurations-including-signatures-to-credentials-on-certificate-update branch 4 times, most recently from af232b5 to a2025de Compare January 7, 2023 17:20
@NikolayBorovenskiy
Copy link
Contributor Author

Hi, @mphilbrick211 looks like that CLA is good now. Thanks for pushing me.

@mphilbrick211 mphilbrick211 added changes requested and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Jan 10, 2023
@NikolayBorovenskiy NikolayBorovenskiy force-pushed the nborovesnkiy/EDXOLDMNG-218/copy-certificate-configurations-including-signatures-to-credentials-on-certificate-update branch 2 times, most recently from 24264b7 to 22d4a7a Compare January 13, 2023 14:42
@NikolayBorovenskiy
Copy link
Contributor Author

@ormsbee Dave, I've pushed all we need. Please verify this. Tnx in advance a lot.

@NikolayBorovenskiy NikolayBorovenskiy force-pushed the nborovesnkiy/EDXOLDMNG-218/copy-certificate-configurations-including-signatures-to-credentials-on-certificate-update branch from 99877a9 to 4015419 Compare January 18, 2023 13:21
@ormsbee
Copy link

ormsbee commented Jan 27, 2023

@NikolayBorovenskiy: Please squash and fix the quality error (sort order of imports) and I'll merge.

@ormsbee ormsbee assigned ormsbee and NikolayBorovenskiy and unassigned ormsbee Jan 27, 2023
@NikolayBorovenskiy NikolayBorovenskiy force-pushed the nborovesnkiy/EDXOLDMNG-218/copy-certificate-configurations-including-signatures-to-credentials-on-certificate-update branch from 28ac275 to c744de0 Compare January 30, 2023 08:53
@NikolayBorovenskiy
Copy link
Contributor Author

@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 NikolayBorovenskiy removed their assignment Jan 30, 2023
@ormsbee ormsbee merged commit bab0b39 into openedx:main Jan 30, 2023
@openedx-webhooks
Copy link

@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.

@timmc-edx
Copy link
Contributor

Would you mind making a quick PR to add this to the changelog as well?

@timmc-edx
Copy link
Contributor

Actually, if you could just review #180 that would be great -- let me know if that summary is correct or not.

@GlugovGrGlib GlugovGrGlib deleted the nborovesnkiy/EDXOLDMNG-218/copy-certificate-configurations-including-signatures-to-credentials-on-certificate-update branch June 13, 2023 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants