Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Proof of concept for new config option: ckanext.xloader.site_url #234
base: master
Are you sure you want to change the base?
Proof of concept for new config option: ckanext.xloader.site_url #234
Changes from 1 commit
43203b8
da5c031
93c9e5f
deab5cb
729d5b3
03a4e67
4b64d4e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
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.
since this snippet is everywhere, can we make a function and place it in a util/helper function so all places can reference the same code.
i.e. instead of just getting the callback_url, it should take a 'url' and replace the 'site_url' with 'xloader.site_url' when set. or append if domain is not available (which is very rare).
In the jobs table . result_url is always a fqdn i.e.
https://www.data.qld.gov.au/api/3/action/xloader_hook
I also see that you dropped
input['result_url']
which containers a lookup of the api endpoint. I'm unsure why we should be 'hacking' the callback_url instead of using a 'generic' replacement function to swap the domain like you are doing to the 'resource' url.The metadata on the 'input' is below
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.
This will break all 'external' url's which are not internally referenced. We should be using a 'generic' function that takes a url and does the swap if the original url.
Details below on my reasoning:
I see in my jobs stats table items is
using this as an example. The input of the _download_resource_data function is
res_dict = get_action('resource_show')(context, {'id': resource_id})
looking at : https://www.data.qld.gov.au/api/action/resource_show?id=5d1e8368-7ec3-435a-92d0-280ad1e3db0d
on line 292, it gets the url which would be:
"url": "https://apps.des.qld.gov.au/data-sets/water/gregory-environmental.csv?timestamp=2025-01-16T10:15:01+10:00",
Which since you are 'force' changing the url, instead of checking its pointing to the CKAN site url first. it would then end up with
http://localhost:5000/data-sets/water/gregory-environmental.csv?timestamp=2025-01-16T10:15:01+10:00
if the ckanext.xloader.site_url is http://localhost:5000
which would then be a 404 or hanging situation.
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.
Thanks @duttonw for taking the time to help me with this. It is much appreaciated.
Yes, I agree that a util/helper function is needed to swap out the CKAN URL
With regards to your scenario, why would you set
ckanext.xloader.site_url
to something if it broke communication? Theckanext.xloader.site_url
config option does not exist at the moment in master. Ifckanext.xloader.site_url
is not set then thecallback_url
would just fall back tockan.site_url
which would exist as it is mandatory. So in your case it would be set tohttp://www.data.qld.gov.au/data-sets/water/gregory-environmental.csv?timestamp=2025-01-16T10:15:01+10:00
as I think yourckan.site_url
is set tohttp://www.data.qld.gov.au
Update: actually if
ckanext.xloader.site_url
is not set, then that config option (ckanext.xloader.site_url
) would be set to the value forckan.site_url
through the validator forckanext.xloader.site_url
in the config_declaration.yaml file. Maybe that's not a great idea if we ever want to keep those 2 parameters distinctThere 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.
Hi @kowh-ai ,
http://www.data.qld.gov.au/data-sets/water/gregory-environmental.csv?timestamp=2025-01-16T10:15:01+10:00 is a 404, since its not on www.data.qld.gov.au, but on apps.des.qld.gov.au (non ckan endpoint)
With the new function
def get_ckan_url():
just update it to take a url. And it would alter it if incoming url 'matches'
ckan.site_url
at the start of the string and replace it withckanext.xloader.site_url
if not empty/blank string. (or if no domain is set, inject).This will still need at least another 5 unit tests for this new function to 'verify' that it does what we expect it to do. i.e. not break external data assets.
somethings i've been thinking for a while is that if you have the 'archiver' plugin installed, like how there is a use case to 'wait' for the validation plugin to complete successfully. If the archiver has 'saved' the resource locally, then we could/should use that ingest into the datastore. The only negative is like these external csv files which are updated adhoc and the 'manual datastore upload' won't collect the latest like it does now. (harvester normally is set up to run on initial upload and then can be setup to run adhoc { for our instance monthly } , this is too slow and will cause frustration for authors who wish to have the latest from an external csv )
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.
This whole section should probably be moved down ten lines or so, to the block where
url_type
isupload
. When the URL type islink
the site URL is not involved in downloading it.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.
@duttonw - What about the other callbacks to CKAN ie: when these 2 functions call
callback_xloader_hook(result_url, api_key, job_dict)
xloader_data_into_datastore()
xloader_data_into_datastore_()
The
result_url
parameter will need to change in a docker network to access the internal CKAN container ie: http://ckan-dev:5000/In your case could the
ckan.site_url
be different to where you want to access the CKAN URL from within the XLoader code? like when you are downloading the resource file? In my case I need to set the CKAN URL tockanext.xloader.site_url
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.
@duttonw - please let me know if the (new)
modify_resource_url()
function will work in this case where theoriginal_url
is different than theckan_url