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

feat: add atlas pull for the communications app FC-0012 #149

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

OmarIthawi
Copy link
Contributor

@OmarIthawi OmarIthawi commented Sep 29, 2023

Adds atlas pull to the Communications MFE. Support for other MFEs will come.

Previously open issues

Here's a couple issues that needs to be tackled:

  • Issue: How to enable the atlas_pull conditionally?
    • Old solution: CORE_MFE_APPS feature.
    • Updated solution: Hard-coded if app_name == communications
  • Issue: How to install openedx-atlas and platform-frontend which are required for atlas pull?
    • Solution: In the package.json of the communications MFE.
  • Issue: Should we use make pull translations? or hand-craft an atlas pull command?
    • For discovery Regis recommended to avoid using make and writing an atlas command instead.
    • For MFEs, it's better to use the Makefile step to allow each frontend to control its own plugins.
  • Issue: After changing directory to cd src/i18n/messages the node_modules/.bin is no longer available.
    • Suggested solution: Use ENV PATH /openedx/app/node_modules/.bin:${PATH} in base instead of the relative PATH.
  • Issue: atlas pull is only available for master because feat: use atlas in make pull_translations openedx/frontend-app-communications#124 is a post-Palm pull request.

TODO before merge

Debug atlas pull and the generated src/i18n/index.js
RUN ls -R /openedx/app/src/i18n/; cat /openedx/app/src/i18n/index.js; exit 1         0.4s
------                                                                                                                        
 > [communications-i18n 4/8] RUN ls -R /openedx/app/src/i18n/; cat /openedx/app/src/i18n/index.js; exit 1:                    
#0 0.385 /openedx/app/src/i18n/:                                                                                              
#0 0.385 index.js                                                                                                             
#0 0.385 messages                                                                                                             
#0 0.385                                                                                                                      
#0 0.385 /openedx/app/src/i18n/messages:
#0 0.385 frontend-app-communications
#0 0.385 frontend-component-footer
#0 0.385 frontend-component-header
#0 0.385 paragon
#0 0.385 
#0 0.385 /openedx/app/src/i18n/messages/frontend-app-communications:
#0 0.385 fr_CA.json
#0 0.385 index.js
#0 0.385 
#0 0.385 /openedx/app/src/i18n/messages/frontend-component-footer:
#0 0.385 ar.json
#0 0.385 de.json
#0 0.385 fr_CA.json
#0 0.385 index.js
#0 0.385 
#0 0.385 /openedx/app/src/i18n/messages/frontend-component-header:
#0 0.385 ar.json
#0 0.385 de.json
#0 0.385 fr_CA.json
#0 0.385 index.js
#0 0.385 
#0 0.385 /openedx/app/src/i18n/messages/paragon:
#0 0.385 ar.json
#0 0.385 de.json
#0 0.385 fr_CA.json
#0 0.385 index.js
#0 0.385 // This file is generated by the openedx/frontend-platform's "intl-import.js" script.
#0 0.385 //
#0 0.385 // Refer to the i18n documents in https://docs.openedx.org/en/latest/developers/references/i18n.html to update
#0 0.385 // the file and use the Micro-frontend i18n pattern in new repositories.
#0 0.385 //
#0 0.385 
#0 0.385 import messagesFromFrontendComponentHeader from './messages/frontend-component-header';
#0 0.385 import messagesFromFrontendComponentFooter from './messages/frontend-component-footer';
#0 0.385 import messagesFromParagon from './messages/paragon';
#0 0.385 import messagesFromFrontendAppCommunications from './messages/frontend-app-communications';
#0 0.385 
#0 0.385 export default [
#0 0.385   messagesFromFrontendComponentHeader,
#0 0.385   messagesFromFrontendComponentFooter,
#0 0.385   messagesFromParagon,
#0 0.385   messagesFromFrontendAppCommunications,
#0 0.385 ];
------

Nightly vs Master

All atlas integration is going to target nightly branches so it's included in Quince but not Palm.

The exception is for the Communications MFE because it has not translations and needs atlas in Palm, therefore it's being used on master.

References

This contribution is part of the FC-0012 project which is sparked by the Translation Infrastructure update OEP-58.

@OmarIthawi

This comment was marked as resolved.

@OmarIthawi OmarIthawi changed the title feat: add atlas pull for the communications app feat: add atlas pull for the communications app FC-0012 Oct 13, 2023
tutormfe/plugin.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

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

I'm adding notes to myself from my call with Adolfo.

@@ -17,7 +17,7 @@ RUN apt update \

RUN mkdir -p /openedx/app /openedx/env
WORKDIR /openedx/app
ENV PATH ./node_modules/.bin:${PATH}
ENV PATH /openedx/app/node_modules/.bin:${PATH}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make pull_translations performs a cd therefore the relative directory PATH won't work.

hopefully it doesn't break anything else 😅

tutormfe/templates/mfe/build/mfe/Dockerfile Outdated Show resolved Hide resolved
tutormfe/templates/mfe/build/mfe/Dockerfile Outdated Show resolved Hide resolved
tutormfe/templates/mfe/build/mfe/Dockerfile Outdated Show resolved Hide resolved
tutormfe/templates/mfe/build/mfe/Dockerfile Outdated Show resolved Hide resolved
tutormfe/plugin.py Outdated Show resolved Hide resolved
@OmarIthawi
Copy link
Contributor Author

@regisb @arbrandes I've tested this pull request which requires the following plugin:

from tutormfe.hooks import MFE_APPS

@MFE_APPS.add()
def _use_comm_mfe_zeitlabs_fork(mfes):
    mfes["communications"] = {
        "repository": "https://github.com/Zeit-Labs/frontend-app-communications",
        "refs": "https://api.github.com/repos/Zeit-Labs/frontend-app-communications/git/refs/heads",
        "version": "atlas-palm",
        "port": 1984,
    }
    return mfes

So it pulls the right repository until the palm.master pull request is merged.

Please review it and let me know what do you think.

@OmarIthawi
Copy link
Contributor Author

OmarIthawi commented Oct 28, 2023

@arbrandes would you mind giving this pull request one more look? Thanks!!

cc: @regisb

# Whenever a new MFE supports Atlas, it should be added to this list.
# When all MFEs support Atlas, this if-statement should be removed.
{% if app_name in ["communications"] %}
RUN make OPENEDX_ATLAS_PULL=true pull_translations
Copy link
Contributor

@regisb regisb Oct 30, 2023

Choose a reason for hiding this comment

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

Are you familiar with the i18-merge.js script from line 53? It's a script that allows anyone to override translation strings. If I understand correctly, running pull_translations here would override this behaviour, thus preventing users from adding their custom translations. Can you confirm? Can we run Atlas in a way that is compatible with this existing feature?

Also, this change is going to break the build for all users who do not run your fork of the communications app, right? We should definitely avoid this, one way or another.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you familiar with the i18-merge.js script from line 53? It's a script that allows anyone to override translation strings. If I understand correctly, running pull_translations here would override this behaviour, thus preventing users from adding their custom translations. Can you confirm? Can we run Atlas in a way that is compatible with this existing feature?

I'm familiar with the script and I should have been clearer in the pull request description that we're going to intentionally not support i18n-merge.js and atlas pull at the same time in this iteration. This will affect the communications MFE which has no translations at the moment so there's no step backward.

Once this PR is merged and used, we'll work on supporting the i18n-merge.js if needed. Our understanding that Atlas provides a superior workflow which makes i18n-merge.js not needed -- at least as we understand it.

This has been confirmed with @arbrandes -- tagging him just in case I missed anything.

Is what I'm mentioning a blocker to merging this PR?

Also, this change is going to break the build for all users who do not run your fork of the communications app, right? We should definitely avoid this, one way or another.

No, of course not. The fork is being used merely for reviewing this pull request, we are fixing this on upstream and it's pending merge:

Copy link
Contributor Author

@OmarIthawi OmarIthawi Nov 4, 2023

Choose a reason for hiding this comment

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

@regisb @arbrandes The openedx/frontend-app-communications#156 pull request has been merged into palm.master. We need the following updates to make Tutor MFE support Atlas without needing a fork:

  • Tag open-release/palm.4 on the communications MFE.
  • Update Tutor open edx version open-release/palm.2 --> open-release/palm.4

This is needed to fix the i18n for the communications app on Palm.

Once this is merged, it will also cause Quince to be supported. The good news that Atlas support already exists in the quince branch: https://github.com/openedx/frontend-app-communications/blob/3e7ea6a3e5d5c35bf508fc7fab067fc5be836e75/Makefile#L52-L62

Until the tags are ready, we'll need the following plugin to make atlas work:

from tutormfe.hooks import MFE_APPS

@MFE_APPS.add()
def _use_comm_mfe_zeitlabs_fork(mfes):
    mfes["communications"]["version"] = "open-release/palm.master"
    mfes["communications"]["refs"] = "https://api.github.com/repos/openedx/frontend-app-communications/git/refs/heads"
    return mfes

Copy link
Contributor

Choose a reason for hiding this comment

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

This will affect the communications MFE which has no translations at the moment so there's no step backward.

Well, it will be a breaking change for users who implemented their own translation strings for the communications MFE. It's a niche use case though, so maybe we can just ignore it.

I agree that Atlas should be a much better solution than that weird i18s-merge.js script. Still, we need to provide users a way to customise translation strings. How are we going to do that in the tutor-mfe plugin?

Tag open-release/palm.4 on the communications MFE.

Publishing a new release tag is a big deal. Do you really need Atlas in Palm? If yes we can ask the BTR to publish a new tag. But maybe it would be sufficient to support Atlas in Quince? You tell me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it will be a breaking change for users who implemented their own translation strings for the communications MFE. It's a niche use case though, so maybe we can just ignore it.
I agree that Atlas should be a much better solution than that weird i18s-merge.js script. Still, we need to provide users a way to customise translation strings. How are we going to do that in the tutor-mfe plugin?

For the communications MFE i18n-merge.js is mostly unused due to completely missing translations. Based on the feedback we've had, no one translated it except for Pierre Mailhot which doesn't use the i18n-merge. For other MFEs, yes it makes sense to add this support.

We've discussed this issue in call with Adolfo and we decided that this iteration won't support i18n merge.

Please let me know if that's still a blocker.

Publishing a new release tag is a big deal. Do you really need Atlas in Palm? If yes we can ask the BTR to publish a new tag. But maybe it would be sufficient to support Atlas in Quince? You tell me.

It's a big deal indeed. Let's refocus our efforts into Quince. I'll check with @sambapete on the idea of skipping Palm for Tutor MFE support, which would leave the Palm users no way to support Atlas except by cherry-picking this pull request. Which isn't pretty bad as long as we land it into Quince.

Choose a reason for hiding this comment

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

That's the keyword "as long as we land it into Quince". Unfortunately, translators translate strings before the cut of Quince.master that took place a month ago. They were never able to translate strings for the communications MFE because it wasn't part any section in the edx-platform project. I only translated it manually for Palm by extracting the strings from the source code because I couldn't leave it untranslated for my users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @sambapete, Quince it is! We're close to do so -- hopefully :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for Quince.

We can still do Palm.4, but it should come after getting Quince up and running.

@OmarIthawi OmarIthawi marked this pull request as draft November 4, 2023 14:14
@OmarIthawi
Copy link
Contributor Author

Status: This is pending the Quince upgrade #156 so I'm presuming that this PR is blocked until the following PR is merged:

cc: @regisb @sambapete @arbrandes

@regisb
Copy link
Contributor

regisb commented Nov 14, 2023

Any change that would added to nightly now would also go to Quince. Do you want to merge this now in nightly?

@arbrandes
Copy link
Collaborator

+1 for getting this into nightly.

@OmarIthawi
Copy link
Contributor Author

OmarIthawi commented Nov 15, 2023

Nightly it is! I'll rebase and get back to you!

@OmarIthawi OmarIthawi changed the base branch from master to nightly November 15, 2023 16:03
@OmarIthawi OmarIthawi marked this pull request as ready for review November 15, 2023 20:28
@OmarIthawi

This comment was marked as duplicate.

@OmarIthawi
Copy link
Contributor Author

@regisb @arbrandes @brian-smith-tcril I've tested this plugin and it worked well without plugins or settings.

image

The only remaining pull request has been merged into master:

Please let me know if there's anything blocking this PR from getting merged.

Copy link
Collaborator

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

Works for me!

@regisb regisb merged commit 0202379 into overhangio:nightly Nov 16, 2023
@arbrandes
Copy link
Collaborator

@OmarIthawi, we're missing openedx-atlas in frontend-app-communications as it stands in Quince. It was introduced in master via openedx/frontend-app-communications#164. I created a backport: openedx/frontend-app-communications#176. Objections?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants