-
Notifications
You must be signed in to change notification settings - Fork 3
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
Exclude courses which have the download button disabled from mirror drives #2282
base: master
Are you sure you want to change the base?
Exclude courses which have the download button disabled from mirror drives #2282
Conversation
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 you please update the testing steps pertaining to local testing with mass build.
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 tested the changes using upsert_mass_build_pipeline --offline
and I can confirm that the courses are excluded from offline mass build that have download button disabled.
I also confirmed that they are excluded only from offline mass build, not the online one.
Looks good to me.
Where can I find a description about how this works? We have a goal of keeping studio indifferent to the project's data schema, and I feel like we're mixing things up here. For example, if we had a project without a "show download" field, will this api still work? |
Yes, it should be alright. It'd return an empty list instead of raising an error if the |
@pdpinch I did suggest this solution, but yea now that you mention it this does go against our philosophy of not adding any application code to |
Could we modify the code in the mass build script instead of the code in Studio? For example, exiting the build early if the download condition isn't met?
Or, another option, could be build something else in this case, instead of the site? Maybe a page with a link?
|
The mass build pipeline is generated by If we do nothing with the @umar8hassan The only thing I might add to this from a code review perspective is that we will also need to do this in |
86665de
to
63b241a
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.
The code for the mass build pipeline is working as expected. I marked a course with hide_download
, regenerated the pipeline and inspected its contents. I looked for the site I marked for exclusion and it was indeed excluded from the offline mass build. This will prevent the offline site from being built and deployed with the offline mass build. I still have a few concerns though. As I mentioned in my above comment, we need a way to keep hide_download
sites out of the offline search index. I see you have done that here in the way I suggested, but now that I've thought about it some more there are some issues with this approach. The update_websites_in_root_website
function is only called when a new site is published for the first time or if a site is being unpublished. We will need to do the following after this PR is deployed if we go with this approach:
- Open a Django shell in the deployed environment and run
update_websites_in_root_website
manually - Run the following management commands:
./manage.py reset_sync_states --filter ocw-www --skip-sync
./manage.py sync_website_to_backend --filter ocw-www --delete
- This will force all the in-progress content on
ocw-www
to be published, so we will need to check with OCW
Alternatively, there is another approach we could take instead that is much more simple. In ocw-hugo-themes
, take a look at the following code from www-offline/layouts/search/section.html
:
{{ range $websites }}
{{ $urlPath := strings.TrimPrefix "/" .Params.url_path }}
{{ $url := printf "%s/%s/index.html" $pathToRoot $urlPath }}
{{ $delimiter := ", " }}
{
"title": "{{- .Title -}}",
"primary_course_number": "{{- .Params.primary_course_number -}}",
"url": "{{- $url -}}",
{{ if .Params.level }}
"level": "{{- delimit .Params.level $delimiter -}}"
{{ else }}
"level": ""
{{ end }}
},
{{ end }}
This code is responsible for iterating content/websites
in ocw-www
and creating the offline FuseJS search index. Here, you could skip over a site if .Params.hide_download
is true. I still think it's worth leaving in the code that excludes sites from having a WebsiteContent
of type website
created, but implementing the above change would mean that updating existing content might be easier as we don't have to delete the sites from the content/websites
folder in ocw-www
.
Now, the reason I have requested changes on this PR is because there is another situation we have to handle in regards to offline sites being deployed that has been overlooked: the single site pipelines. When a single site publish is triggered, the online site build job is followed by the offline job:
We could make a code change to site_pipeline.py
to exclude the offline build job if hide_download
is true, but I'm not sure this would be the best approach. In order for this to take effect, a given pipeline needs to be backpopulated into Concourse. If a content author sets a site to hide download, the pipeline definition in Concourse is not updated as part of that.
With all this taken into consideration, I'm thinking about how @pdpinch suggested that we instead prevent the whole build from happening within the pipeline somehow. One way to do this would be to add another get step that the offline job depends on similar to offline_build_gate
, a keyval
type resource. Its job would be to check hide_download
and not pass to the offline build job if it's true.
@umar8hassan @gumaerc what's next with this? Is it worth merging as is, and returning to "prevent the whole build from happening within the pipeline somehow" at a later date -- or should we stop this now? |
@pdpinch I believe we should deal with this now. If this is merged as-is, offline versions of sites marked with |
…ot downloadable sites
63b241a
to
8799e5f
Compare
What are the relevant tickets?
closes https://github.com/mitodl/hq/issues/4473
Description (What does it do?)
This excludes the sites in offline mass build which has
hide_download
button set for them.How can this be tested?
main
branch inocw-studio
localhost:8043/sites
or use existing onehide_download
toTrue
docker-compose exec web ./manage.py mass_publish <live/draft> --filter <site-name>
and wait for the build to complete successfully.minio
console atlocalhost:9001
and check course data inocw-content-offline-<live/draft>-local/courses/<site-name>
for your site.umar/4473-exclude-courses-which-have-the-download-button-disabled-from-mirror-drives
inocw-studio
2 - 6
and data should not be updated foroffline
version sites.