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

dataset get file list broken for v2, route changed on v2 backend #100

Merged

Conversation

tcnichol
Copy link
Contributor

@tcnichol tcnichol commented Mar 30, 2024

To replicate the bug:

Run a dataset extractor (I ran the huggingface ray extractor.)

In connectors._build_resource these lines cause an error:

 datasetinfo = pyclowder.datasets.get_info(self, host, secret_key, datasetid)
                filelist = pyclowder.datasets.get_file_list(self, host, secret_key, datasetid)
                triggering_file = None
                for f in filelist:
                    if f['id'] == fileid:
                        triggering_file = f['filename']
                        break

This is because what is returned by the /files endpoint in the dataset router has changed. Before it was just a list of files, and now the response is the Paged response, which contains a "metadata" and "data." When it tries to find the f["id"] in those objects, it is not there so it throws an error.

My fix will be to have datasets.get_file_list to return the files, which is the "data" field coming from the backend route.

…s related to the pagination, and the data is the actual list of files. We want to get the list of files here only, or else other parts of the code will break.
@tcnichol tcnichol linked an issue Mar 30, 2024 that may be closed by this pull request
@tcnichol tcnichol requested review from ddey2 and max-zilla March 30, 2024 17:56
@tcnichol tcnichol changed the title the backend route returns 2 fields: metadata and data. The metadata i… dataset get file list broken for v2, route changed on v2 backend Mar 30, 2024
@tcnichol tcnichol requested review from longshuicy and lmarini March 30, 2024 19:56
@@ -128,7 +128,7 @@ def get_file_list(connector, host, key, datasetid):
datasetid -- the dataset to get filelist of
"""
client = ClowderClient(host=host, key=key)
file_list = datasets.get_file_list(connector, client, datasetid)
file_list = datasets.get_file_list(connector, client, datasetid)['data']
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this change be in pyclowder/v2/datasets.py rather than here? i dont think the v1 endpoint will have a data field, so it might break back compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be fixed now.

@Vismayak
Copy link
Contributor

Just needs to be rebased but works! 😄

…-of-list-of-files
@max-zilla max-zilla merged commit 912423a into master Jun 17, 2024
9 checks passed
@max-zilla max-zilla deleted the 99-dataset-file-list-returns-paged-instead-of-list-of-files branch June 17, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dataset file list returns paged instead of list of files
4 participants