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

IRSA-6468: Support for Packager Script of URLs (Euclid, SphereX, Rubin, etc.) #1690

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

kpuriIpac
Copy link
Contributor

@kpuriIpac kpuriIpac commented Jan 11, 2025

Ticket: IRSA-6468

  • IFE PR
  • Based on feedback, created a DownloadSciptWorker based on our existing PackagingWorker with changes to write out the URLs to a script made available for download (instead of zipped files of products)
  • Client can specify the script type (curl, wget or plain list of urls)
  • Removed cutout option from the UI (a new ticket will address this item).
  • Modified DownloadScript.java to support better filename generation from the given URL
  • Made some changes in the DownloadButton and DownloadOptionPanel components to accept the download button text (instead of Prepare Download)
  • DownloadOptionPanel and PackageRequest (in SearchServicesJson.js) now accept a new parameter: downloadType. This determines whether we use our traditional packager or the new download script.
  • Got rid of downloading data to a tmp file in ObsCorePackagaer.java

Testing:

@kpuriIpac kpuriIpac added this to the 2025.1 milestone Jan 11, 2025
@kpuriIpac kpuriIpac requested a review from robyww January 11, 2025 03:57
import static edu.caltech.ipac.util.FileUtil.getUniqueFileNameForGroup;

@SearchProcessorImpl(id = "PackagerScript")
public class PackagerScript extends FileGroupsProcessor {
Copy link
Contributor

Choose a reason for hiding this comment

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

This class implementation is not right. If it's a generic, reusable script generator, then it should not have any ObsCore logic. If it's an ObsCore data packager, then it is named wrong and there is already an ObsCorePackager.

Copy link
Contributor

@loitly loitly left a comment

Choose a reason for hiding this comment

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

The solution should be divided into two parts:

  • Verify that the script generator functions as intended.
  • Modify the UI and server code to support a "create download script" option as an alternative to the existing "package download" data feature.

I thought that this PR was suppose to address the first part. In any case, the implementation is not what I expected.

@robyww robyww modified the milestones: 2025.1, 2025.2 Jan 13, 2025
@kpuriIpac kpuriIpac force-pushed the IRSA-6468-packager-script branch 4 times, most recently from 5bf920a to b499a06 Compare January 15, 2025 04:24
@kpuriIpac kpuriIpac marked this pull request as ready for review January 15, 2025 04:37
Comment on lines 71 to 77
File tmpFile = File.createTempFile("obscorepackager-", ".download", ServerContext.getTempWorkDir());
FileInfo tmpFileInfo = URLDownload.getDataToFile(url, tmpFile);
String contentType = tmpFileInfo.getAttribute(HttpResultInfo.CONTENT_TYPE);

//todo: replace tmpFile code above with this, or else remove this commented out code
//HttpResultInfo r= URLDownload.getDataFromURL(new URL(access_url), null, null, null);
//String contentType = r.getContentType();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI @robyww @loitly

  • based on our discussion, I had thought about removing the tmpFile code, as we could just use access_format to get the extension, but I realized that the else case (~line 103) is actually triggered when access_format is null. So I have left this code and the commented out line here for now, but we can discuss it.

@kpuriIpac kpuriIpac force-pushed the IRSA-6468-packager-script branch from b499a06 to 80b64e8 Compare January 16, 2025 00:41
@kpuriIpac
Copy link
Contributor Author

@robyww @loitly:

Since the PR description is a bit detailed, here's a short summary of today's final changes:

  • DownloadOptionPanel and PackageRequest (in SearchServicesJson.js) now accept a new parameter: downloadType. This determines whether we use our traditional packager or the new download script.
  • Got rid of downloading data to a tmp file in ObsCorePackagaer.java
  • cutout has been removed from the UI as an option in Euclid

Follow the testing instructions above and in the IFE PR, but a quick summary for testing as well:

  • test doing an Image search in Euclid, and download all 3 script types (curl, wget, plain urls)
  • test doing an Inspect Objects and Search by ID search in Euclid as well (this is just to ensure Euclid is ready for our internal release)
  • Test doing a CADC ivoa ObsCore search in firefly tap, then select a few rows and click Prepare Download. Ensure this behaves the same as before (you should get a zipped file with the data products).

Copy link
Contributor

@loitly loitly left a comment

Choose a reason for hiding this comment

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

Looks good. Minor cleanup then you're good to go.

Comment on lines 61 to 65
public static final String PRODUCTS = "productTypes";
public static final String SCRIPT = "scriptType";
public static final String ACCESS_URL = "access_url";
public static final String ACCESS_FORMAT = "access_format";
public static final String SEMANTICS = "semantics";
Copy link
Contributor

Choose a reason for hiding this comment

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

These constants should not be here.

Comment on lines 182 to 183
private static String makeDownloadUrl(File f, String suggestedName) {
String fileStr = ServerContext.replaceWithPrefix(f);
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to copy/paste this function here. Change PackagingWorker.makeDownloadUrl accessor to public or package protected(remove private) then use it instead.

Comment on lines 134 to 135
showFileLocation=true, showTitle=true,
downloadButtonText='Prepare Download', downloadType='package', ...props}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We could derive downloadButtonText and similarly buttonText from downloadType to avoid redundancy. However, I'm open to whichever approach you prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

did this for downloadButtonText based on your suggestion, left buttonText as is, since it's passed to the DownloadButton component (as opposed to DownloadOptionPanel)

@kpuriIpac kpuriIpac force-pushed the IRSA-6468-packager-script branch from d246852 to 949d4fe Compare January 16, 2025 19:25
@@ -155,15 +156,12 @@ public static List<FileInfo> parseDatalink(URL url, String prepend_file_name, St
ext_file_name = makeDataLinkFolder ? prepend_file_name + "/" + ext_file_name : ext_file_name;
}

if (products != null) {
// Check if products exist and contains sem
if (products != null) { // Check if products exist and contains sem
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@robyww @loitly I left this as a null check, because I add a check for null & empty for the string productTypes at the beginning on computeFileGroup function above.


// Extract the last part of the path
String path = url.getPath();
if (path != null && !path.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

use StringUtils.isEmpty

@kpuriIpac kpuriIpac force-pushed the IRSA-6468-packager-script branch from 26c985b to a831bbc Compare January 16, 2025 22:56
@kpuriIpac kpuriIpac merged commit 16da88e into dev Jan 16, 2025
@kpuriIpac kpuriIpac deleted the IRSA-6468-packager-script branch January 16, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants