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

Added multiple file download API #2962

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

koolgax99
Copy link
Contributor

Description

Added a REST API to download multiple file of a workflow.

The endpoint for the api is /api/workflows/{id}/file-multiple/ the file list is provided in the request body in json format and it is a POST request.

Sample body: { "files": [ "pecan.xml", "workflow.R" ] }

Screenshot of the API:
image

Motivation and Context

This comes in handy for various researchers to download multiple files from a workflow. Earlier =, a researcher could only download a single file at a time via the /api/workflows/{id}/file/{filename}

The issue created for this feature is #2940

Review Time Estimate

  • Immediately
  • Within one week
  • When possible

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • My name is in the list of CITATION.cff
  • I have updated the CHANGELOG.md.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@koolgax99
Copy link
Contributor Author

@istfer can you test and review the API

@istfer istfer self-assigned this Jul 19, 2022
}
else {
file_names <- list()
file_names <- list.files(paste0(Sys.getenv("DATA_DIR", "/data/"), "workflows/PEcAn_", id))
Copy link
Member

Choose a reason for hiding this comment

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

If you're querying the database to see if a workflow exists, why are you then making very strong (and often false) assumptions about where the workflow folder is rather than just looking at the folder that's stored in BETY?

full_files <- vector(mode = "character", length = length(filenames))
for (i in 1:length(filenames)) {

# Check if the requested file exists on the host
Copy link
Member

Choose a reason for hiding this comment

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

If you're doing this check both here and in the last function then it seems like a good place to create a function that does the check. That way you only need to fix errors in one place? This code has the same filepath error as the previous and neither seems to be checkin whether the workflow being queried is on the local machine or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure sir, Ill try to have a single function for both of them!

parameters:
- in: query
name: pft_id
description: If provided, returns all posteriors for the provided model_id
Copy link
Member

Choose a reason for hiding this comment

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

typo between pft_id and model_id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes sir Ill fix this typo

apps/api/pecanapi-spec.yml Outdated Show resolved Hide resolved
@mdietze
Copy link
Member

mdietze commented Jan 11, 2023

@koolgax99 checking to see if you had plans to address the requested changes at some point

@koolgax99
Copy link
Contributor Author

Yes @mdietze! I'll start fixing them, was caught up with other issues.

@mdietze
Copy link
Member

mdietze commented Mar 21, 2023

@koolgax99 just pinging you again about finishing up this PR

@mdietze
Copy link
Member

mdietze commented Apr 26, 2023

@koolgax99 checking back in about this PR. Would be good to wrap this and your other open PRs up

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.

5 participants