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

Fix part of #5002 remove GCS_RESOURCE_BUCKET_NAME from GLOBALS #7130

Merged
merged 23 commits into from
Jul 25, 2019

Conversation

jameesjohn
Copy link
Contributor

Explanation

Fixes part of #5002 remove GCS_RESOURCE_BUCKET_NAME from GLOBALS

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The linter/Karma presubmit checks have passed.
    • These should run automatically, but if not, you can manually trigger them locally using python scripts/pre_commit_linter.py and bash scripts/run_frontend_tests.sh.
  • The PR is made from a branch that's not called "develop".
  • The PR has an appropriate "CHANGELOG: ..." label (If you are unsure of which label to add, ask the reviewers for guidance).
  • The PR follows the style guide.
  • The PR addresses the points mentioned in the codeowner checks for the files/folders changed. (See the codeowner's wiki page.)
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer and don't tick this checkbox.
    • If you're not sure who the appropriate reviewer is, please assign to the issue's "owner" -- see the "talk-to" label on the issue. Do not only request the review but also add the reviewer as an assignee.

@jameesjohn jameesjohn requested a review from kevinlee12 as a code owner July 12, 2019 11:33
@codecov
Copy link

codecov bot commented Jul 12, 2019

Codecov Report

Merging #7130 into develop will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #7130      +/-   ##
===========================================
+ Coverage    98.06%   98.06%   +<.01%     
===========================================
  Files          377      379       +2     
  Lines        63086    63116      +30     
===========================================
+ Hits         61864    61894      +30     
  Misses        1222     1222
Impacted Files Coverage Δ
feconf.py 99.46% <100%> (ø) ⬆️
main.py 87.73% <100%> (+0.11%) ⬆️
core/controllers/app_identity_test.py 100% <100%> (ø)
core/controllers/app_identity.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f52947f...3c169e3. Read the comment docs.

@codecov
Copy link

codecov bot commented Jul 12, 2019

Codecov Report

Merging #7130 into develop will decrease coverage by 9.28%.
The diff coverage is 64.58%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #7130      +/-   ##
===========================================
- Coverage    98.62%   89.34%   -9.29%     
===========================================
  Files          381     1198     +817     
  Lines        64057    96865   +32808     
  Branches         0     2469    +2469     
===========================================
+ Hits         63179    86544   +23365     
- Misses         878     9806    +8928     
- Partials         0      515     +515
Impacted Files Coverage Δ
...ge/directives/OppiaNoninteractiveImageDirective.ts 18.42% <ø> (ø)
core/controllers/base.py 100% <ø> (ø) ⬆️
main.py 87.61% <ø> (ø) ⬆️
...jects/templates/ImageWithRegionsEditorDirective.ts 0.76% <0%> (ø)
...sions/objects/templates/FilepathEditorDirective.ts 0.85% <0%> (ø)
...ctives/OppiaInteractiveImageClickInputDirective.ts 8.13% <0%> (ø)
core/controllers/resources_test.py 100% <100%> (ø) ⬆️
core/controllers/resources.py 100% <100%> (ø) ⬆️
...s/dev/head/services/AssetsBackendApiServiceSpec.ts 99.11% <100%> (ø)
feconf.py 99.45% <100%> (ø) ⬆️
... and 818 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50e8ae3...f6ee206. Read the comment docs.

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! Few comments.

core/controllers/app_identity.py Outdated Show resolved Hide resolved
window.MSBlobBuilder;
window.WebKitBlobBuilder ||
window.MozBlobBuilder ||
window.MSBlobBuilder;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unnecessary. I think it is due to my editor formatting.
Removed.

GCS_PREFIX = ('https://storage.googleapis.com/' +
GCS_RESOURCE_BUCKET_NAME + '/exploration');
AUDIO_DOWNLOAD_URL_TEMPLATE = (
(DEV_MODE ? '/assetsdevhandler' : GCS_PREFIX) +
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to check DEV_MODE here? Shouldn't this be handled on line 51?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, removed.

var _initialize = function() {
if (DEV_MODE) {
// GCS_PREFIX = ('https://storage.googleapis.com/' +
// GCS_RESOURCE_BUCKET_NAME + '/exploration');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The prefix is only used in PROD

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! Few comments.

@@ -63,19 +61,17 @@ oppia.factory('AssetsBackendApiService', [
}

$http.get('/appidentityhandler').then(function(response) {
if (!DEV_MODE && !response.data.GCS_RESOURCE_BUCKET_NAME) {
if (!response.data.GCS_RESOURCE_BUCKET_NAME) {
throw Error('GCS_RESOURCE_BUCKET_NAME is not set in prod.');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that I think of it. Remove this if altogether.

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 don't think this if should be removed since it validated the result gotten from the handler

@@ -63,19 +61,17 @@ oppia.factory('AssetsBackendApiService', [
}

$http.get('/appidentityhandler').then(function(response) {
if (!DEV_MODE && !response.data.GCS_RESOURCE_BUCKET_NAME) {
if (!response.data.GCS_RESOURCE_BUCKET_NAME) {
throw Error('GCS_RESOURCE_BUCKET_NAME is not set in prod.');
}
GCS_RESOURCE_BUCKET_NAME = response.data.GCS_RESOURCE_BUCKET_NAME;
}).then(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to chain the .then( here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No
Removed. Thanks.

@jameesjohn jameesjohn reopened this Jul 22, 2019
@oppiabot
Copy link

oppiabot bot commented Jul 23, 2019

Hi @Jamesjay4199. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks!

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Took another pass, thanks @Jamesjay4199.

Could you please describe your manual testing procedure for this PR? I suggest doing that in general for PRs that you do from now onwards, in order to avoid cases like the recent regressions.

var IMAGE_DOWNLOAD_URL_TEMPLATE = (
(DEV_MODE ? '/assetsdevhandler' : GCS_PREFIX) +
'/<exploration_id>/assets/image/<filename>');
if (_initialized) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should come at the very beginning of the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


var AUDIO_UPLOAD_URL_TEMPLATE =
'/createhandler/audioupload/<exploration_id>';
$http.get('/gcs_resource_bucket_name_handler').then(function(response) {
Copy link
Member

Choose a reason for hiding this comment

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

Don't you need to return this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. Done.

exploration_id: explorationId,
filename: filename
});
if (_initialized) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this clause? I thought the "if _initialized" check in _initialize() should take care of it seamlessly. It would be better to drop lines 230-238 as long as you verify the code is still correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks.

@@ -96,8 +96,12 @@ oppia.directive('oppiaInteractiveImageClickInput', [
// preview mode. We don't have loading indicator or try again for
// showing images in the exploration editor or in preview mode. So
// we directly assign the url to the imageUrl.
ctrl.imageUrl = AssetsBackendApiService.getImageUrlForPreview(
ContextService.getExplorationId(), ctrl.filepath);
AssetsBackendApiService.getImageUrlForPreview(
Copy link
Member

Choose a reason for hiding this comment

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

For async methods can you rename them to have async in the name? E.g. getImageUrlForPreviewAsync, get TrustedResourceUrlForImageFileNameAsync, etc.

Ditto elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

LGTM!

@seanlip
Copy link
Member

seanlip commented Jul 24, 2019

Backend tests are failing, @Jamesjay4199 .

@seanlip
Copy link
Member

seanlip commented Jul 24, 2019

Also, did you see this comment? Please address it.

Could you please describe your manual testing procedure for this PR? I suggest doing that in general for PRs that you do from now onwards, in order to avoid cases like the recent regressions.

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks, looks good @Jamesjay4199. Just one small comment.

That said, the bigger comment is the one about manual testing. Please address that. I will wait on that before giving LGTM.

@@ -227,22 +227,13 @@ oppia.factory('AssetsBackendApiService', [
};

var _getDownloadUrl = function(explorationId, filename, assetType) {
Copy link
Member

Choose a reason for hiding this comment

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

Change to _getDownloadUrlAsync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@jameesjohn
Copy link
Contributor Author

Could you please describe your manual testing procedure for this PR? I suggest doing that in general for PRs that you do from now onwards, in order to avoid cases like the recent regressions.

Sorry for the delays, I did the testing again to confirm.
For manual testing, I created an exploration, did a voice over, then played the exploration. While playing the exploration, I played the audio which I loaded.

However, I think there should be more testing since the bucket name is going to be null while testing it locally.

@seanlip
Copy link
Member

seanlip commented Jul 25, 2019

Thanks for confirming @Jamesjay4199. I'll add a note to the August release notes doc to make sure to verify this when we push to the test server, though typically you should be testing this on your own deployment.

@seanlip seanlip merged commit a7bb506 into oppia:develop Jul 25, 2019
expect(
AssetsBackendApiService.getAudioDownloadUrl('expid12345', 'a.mp3')
).toEqual('/assetsdevhandler/expid12345/assets/audio/a.mp3');
AssetsBackendApiService.getAudioDownloadUrlAsync('expid12345', 'a.mp3')
Copy link
Member

Choose a reason for hiding this comment

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

@Jamesjay4199 I just realized something (after I merged) about this test. Change the URL on line 70 to something random and run the frontend tests. Do they pass?

If so, please rework this test to call done() after the async call. See https://jasmine.github.io/2.0/introduction.html#section-Asynchronous_Support. Do this for other async calls.

Please address this in a separate follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

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

@seanlip
Copy link
Member

seanlip commented Jul 25, 2019

Also, @Jamesjay4199, please do a test of this functionality on a prod server of your own. If you have trouble doing that please email me and Vojta and we can help you get it set up. If this causes problems during the release -- that would not be great.

/cc @vojtechjelinek

@jameesjohn jameesjohn mentioned this pull request Aug 2, 2019
9 tasks
jameesjohn added a commit to jameesjohn/oppia that referenced this pull request Aug 2, 2019
seanlip pushed a commit that referenced this pull request Aug 3, 2019
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.

9 participants