Support dataset-cover-image.png upload for datasets metadata --update#969
Support dataset-cover-image.png upload for datasets metadata --update#969
dataset-cover-image.png upload for datasets metadata --update#969Conversation
There was a problem hiding this comment.
changes to this file are from ./docker-hatch run lint:fmt
| if os.path.isabs(relative_or_absolute_image_file_path): | ||
| image_full_path = relative_or_absolute_image_file_path | ||
| else: | ||
| image_full_path = os.path.join(metadata_file_path, relative_or_absolute_image_file_path) |
There was a problem hiding this comment.
This is the main code change in this PR.
We check if the image file path is absolute instead of assuming it is always relative
Interesting. Does that mean that the metadata JSON is also baked into the dataset in these cases? |
Actually, I found the answer. It looks like we exclude it from the upload: kaggle-cli/src/kaggle/api/kaggle_api_extended.py Line 4920 in f74b05b dataset-cover-image.(png|jpg...) that's co-located with the metadata JSON, and then if present, we pull that to work our magic. WDYT? Then users don't even have to put it in their metadata JSON, right?
|
|
FYI: When Steve and I discussed this FR before our OOO, we were leaning towards using a co-located file with a specific name for the header image as Goeff suggested above. |
Ah, that's a smart idea, i wish i thought about that before. 😬 🤦 Given we supported relative path already for Adaption Labs, I'll update the PR to use I'll update docs to document the |
b814c9c to
ed20d6c
Compare
@rosbo @stevemessick I updated to use this approach, PTAL. Thanks again for the suggestion. |
dataset-cover-image.png upload for datasets metadata --update
Follow-up to #959
Requiring the dataset cover / thumbnail image to be in the same dir as
dataset-metadata.jsonmeans that if you create a dataset withkaggle datasets create --dir-mode=(zip|tar), the metadata image will be included in your dataset files, which the author may not want. I had set it up that way because it adhered to Data Package spec, but it's kind of annoying.This PR adds a special named file,
dataset-cover-image.(png|jpg|jpeg|webp)in the same location as yourdataset-metadata.jsonto provide it as the image upload, without including it in your dataset./some/path/dataset-metadata.json(not uploaded)/some/path/my-files/*(uploaded)/some/path/dataset-cover-image.png(not uploaded)We still support relative path via "image" property to adhere to Data Package spec. This was the first form of the API for Adaption Labs (and we don't want to break them), but there's also an edge case scenario where you want to re-use an image in your dataset as the cover image.
Local testing:
Note: there are some other random changes that showed up from running
./docker-hatch run lint:fmthttp://b/500108129