-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow to add metadata when uploading a resource #12862
Comments
Hi @ridoo
geonode/geonode/upload/handlers/common/vector.py Lines 702 to 710 in 306a958
As you can see are field handled by the serializer: geonode/geonode/upload/api/serializer.py Lines 41 to 42 in 306a958
If the XML (ISO metadata or Dublin core) is not the way you want to upload the data, you can define your custom Lines 2219 to 2224 in 306a958
This existing way, works for both GN5 and GN44x |
@mattiagiupponi indeed XML would be too verbose and cumbersome for just one property. But |
@mattiagiupponi Looking into it, it seems that METADATA_STORER is meant to calculate things after an instance has been stored (see resource.regions_storer.spatial_predicate_region_assignor). However, what is missing from As described above, wouldn't it be just enough to let the importer read and pass those defaults? |
@mattiagiupponi I see these change necessary to make this work:
Sending the request seem to work (the
Do you see any problems with this? I could provide a PR on |
Hi @ridoo
I dont see any problem in this. Will for sure speedup the resource creation via import. The only thing i'm worried about are the foreign key with the resource such as keywords, thesaurus, categories etc...
This would be amazing!
How big could be the refactor in your opinion? If we can improve something i'm always happy to do it. The idea of how to pass it, looks good to me |
Hm, do you think of something specific here (permissions, or similar)? I can come up with something (by this week) and we can test and see, what dragons we have to deal with. |
I'll take the keyword as example. there is the Handler for managing the keyword: geonode/geonode/resource/utils.py Line 62 in 306a958
The handler already tries to decide if is a normal keyword or if is a thesaurus one, but is based on how the metadata parsers return them. Let's assume the following scenario:
Notes:
|
@mattiagiupponi Using a custom metadata storer we would be totally free to store whatever is needed. Are you having something more general in mind? If you think of a general storer which is enabled by default and works in combination with XML metadata:
I would start simple and document limitations on the go. Then we can decide what to include or postpone with regard to the PR. |
Sounds good for now, i would go with "JSON payload overrides XML"
u are right
great
Agree, let's keept is simple for now I'm waiting for ur pr :) |
@mattiagiupponi there were changes to the API which now require the Edit: Other observations:
|
Commenting on my observations to document decisions I made.
For now, I will expect
TBH, this is weird when reading the code and makes a bit uncertain reading the code, however, will not block this feature.
This observation does not block working on this feature. However, these errors also appear on
This one seems to be the only issue which I need some feedback for. It seems,
@mattiagiupponi what do you think? Is this worth an extra issue? |
Hi @ridoo
We decided to enforce it, to let the
I guess this is due to not a proper cleaning during few commits. But in the end no it not going to invalidate the if/else because they are converting info into object and if you notice the
Actually no, this needs to be investigated. It happen in docker or locally?
Yes, it should create GroupProfile
Yes, better to open another issue |
So, what is the code supposed to expect? Do we want the code to raise an exception in case the
Happens on docker (see the geonode test case)
I created the issue here: #12875 |
Dropping here late in the discussion I'm afraid... |
@ridoo what about adding a jsonschema instance payload in the resource manager https://github.com/GeoNode/geonode/blob/master/geonode/metadata/manager.py#L131 I guess it would be a lot simpler. |
Hi @ridoo
This will be a huge step forward with the idea of let the metadata manager handle all the metadata in GeoNode and this can be the first step. The metadata manager is expecting a payload like exposed in this test: What do you think? is something that will solve also your requirement?
Of course i'll assist about the test, i'll not leave you alone 😄 |
@etj @mattiagiupponi my concrete use case is at
However, both was not suitable for my use case, so I decided to add such feature via this PR, hoping it would be backported. I see, that using the metadata editor makes more sense here. Unfortunately, this brings me a bit farther away from serving my actually use case. Anyway, I will have a look tomorrow. @etj do you think we can move my current approach to |
Is your feature request related to a problem? Please describe.
Currently, datasets upload via importer does not serialize any metadata payload which could be set during import process. This requires either to
However, both approaches are either cumbersome (metadata editor) or would require two requests, which may end up in eventual consistency in case of network failure.
Describe the solution you'd like
The importer already takes data payload to offer some control over the import process (overwrite, skip existing layers, etc.). I can imagine a
data
field which would take (if necessary a reduced set of) attribute values to be set directly when creating the resource. For example:On import the handler would pass the
data
as**kwargs
:Describe alternatives you've considered
As said before, a two-step workflow (upload and patch) may work too, but
Additional context
It seems, that
upload.models.py#Upload
(fromv4.4
) had been refactored to useResourceBase
model (part of the metadata API refactoring, I guess). However, it also misses the payload serialization which would be very convenient during API upload.For the time being, I am still on
v4.4
but tend to upgrade tov5
if you think, this should be part of the next version. However, I also would be happy to find a quick solution forv4.4
. For example, the metadata field in the oldUpload
model looked promising to me on a first glimpse.Any hints welcome :)
The text was updated successfully, but these errors were encountered: