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 ckanext-file-uploader #233

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ChasNelson1990
Copy link
Member

@ChasNelson1990 ChasNelson1990 commented Jan 23, 2025

Description

Removes all the previous file uploader JS, CSS and templates and instead install v1.0.0 of the new ckanext-file-uploader.

relates fjelltopp/ckanext-file-uploader#2
relates fjelltopp/fjelltopp-infrastructure#343

Dependency Changes

Added ckanext-file-uploader==v1.0.0-rc1 to Pipfile and locked.

Testing

Have run zarr-ckan locally with these changes and everything is working as expected.

Environment Changes

Have updated bootstrap.sh based on the pattern @A-Souhei introduced with fjelltopp-theme.

Checklist

  • The GitHub ticket for this issue has been updated to "Ready to Review" or equivalent.
  • I have developed these changes in discussion with the appropriate project manager.
  • My code follows the general Fjelltopp documentation (see Confluence).
  • I have made corresponding changes to the Fjelltopp documentation (see Confluence).
  • I have rebased this branch with master.
  • New dependency changes have been committed.
  • I have added automated tests that prove my fix is effective or that my feature works.
  • New and existing tests pass locally with my changes.
  • My changes generate no new warnings.
  • I have performed a self-review of my own code.
  • I have assigned at least one reviewer.
  • I have assigned at least one label to this PR: "patch", "minor", "major".

@ChasNelson1990 ChasNelson1990 added enhancement New feature or request minor labels Jan 23, 2025
@ChasNelson1990 ChasNelson1990 self-assigned this Jan 23, 2025
A-Souhei
A-Souhei previously approved these changes Jan 24, 2025
Copy link
Contributor

@A-Souhei A-Souhei 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 on local!

Update: the GA extension is missing so after creating a dataset, CKAN will crash because {{ h.get_package_stats(package.id) }} is not found in package_item

@A-Souhei A-Souhei dismissed their stale review January 24, 2025 08:01

{{ h.get_package_stats(package.id) }} is not found

Copy link
Member

@jonathansberry jonathansberry left a comment

Choose a reason for hiding this comment

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

This one confused me for a while and I probably spent too long reviewing it. But theres something slightly odd I think. Take a look at my thoughts and see what you think?

@@ -75,6 +75,7 @@ ckanext-scheming = {editable = true, ref = "8d62a28370c4f231dbf2f9688ede93a03564
ckanext-versions = {editable = true, ref = "3a6094acd730f3495b0f8b99b14a2340042a721b", git = "https://github.com/datopian/ckanext-versions"}
ckanext-dcat = {editable = true, ref = "51d651315ff2ff594ebd6eb1d658bc7e9553310c", git = "https://github.com/ckan/ckanext-dcat"}
ckanext-short-urls = {editable = true, ref = "2.0.0", git = "https://github.com/fjelltopp/ckanext-short-urls"}
ckanext-file-uploader = {editable = true, ref = "1.0.0-rc2", git = "https://github.com/fjelltopp/ckanext-file-uploader"}
Copy link
Member

Choose a reason for hiding this comment

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

why "rc2"?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the second release candidate (because there was nothing on main to release); I can update it now we've merged.
(I probably should have kept this as draft whilst it was pointing to a release candidate but I forgot lol)

# Build React components
cd /usr/lib/ckan/ckanext-zarr/ckanext/zarr/react/ && \
npm install && \
# Build fjelltopp file uploader js and css files
Copy link
Member

Choose a reason for hiding this comment

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

There's something slightly odd about this file to me, it's a little tricky to articulate it clearly. It looks like this is trying to be a general solution for all projects, but is found in a project-specific file, and then still needs to know the domain of a certain projects. So it's a sort of half way house being neither general or specific?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, so all I've done here is copy the pattern we already use for theme. I would love there to be a more generic solution - the ideal would be a way to run scripts on spin up from within a CKAN extension but I don't thiiiink that's possible is it?

if [ -d "$FILE_UPLOADER" ]; then
cd "$FILE_UPLOADER/react"
# nvm use
if [ "$CKAN_SITE_URL" = "http://zarr.minikube" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Presumably the purpose of this line is to determine fi you are in the local env or not?

Sometimes I really wish the CKAN pod just had an env var that told us which environment we were in. There's been a few occasions I wanted this. It really shouldn't be hard right - just print the contents of an ansible var into an ENV VAR in the ckan.yaml kubernetes template? I feel sure I raised this before and was told there was a reason why this was a bad idea.

Anyhow, this line confused me for quite a while and looked like a code sniff as it makes this code block project-specific whereas otherwise it would be general across all projects. Can we at least put in an explanatory comment?

Comment on lines +4 to +5
FILE_UPLOADER="$CKAN_VENV/src/ckanext-file-uploader"
if [ -d "$FILE_UPLOADER" ]; then
Copy link
Member

@jonathansberry jonathansberry Jan 24, 2025

Choose a reason for hiding this comment

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

So it's these lines that make the file feel like it is written to be general across all projects. Are they needed? or will we only copy and paste this code block into projects where ckanext-file-uploader is installed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I agree with your thoughts on this - maybe we can brainstorm a better solution.

@ChasNelson1990
Copy link
Member Author

Update: the GA extension is missing so after creating a dataset, CKAN will crash because {{ h.get_package_stats(package.id) }} is not found in package_item

@A-Souhei - this is the Google Analytics issue that I raised with you so you're the one fixing this 🤣

@ChasNelson1990
Copy link
Member Author

@jonathansberry - is the Plugin Observer interface the right way to do this initialisation work in a general fashion? https://docs.ckan.org/en/2.11/extensions/plugin-interfaces.html#ckan.plugins.interfaces.IPluginObserver

@A-Souhei
Copy link
Contributor

A-Souhei commented Jan 27, 2025

@ChasNelson1990
I confirm this works on local, can't approve because I removed my review earlier, my bad!
Relates this PR https://github.com/fjelltopp/fjelltopp-infrastructure/pull/345 that is a WIP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants