planet-client-python icon indicating copy to clipboard operation
planet-client-python copied to clipboard

Save final orders as order_name instead of order_id

Open aayushmalik opened this issue 1 year ago • 7 comments

Current Problem

As a customer, I give each tasking order a unique name which is how I identify these orders in my organisation. For example, 1406_XY_XZ_LST, but when I download these fulfilled orders, the final folder name (or zipped file) is saved as order-id, which is good for Planet's systems, but not for me as a final user. This increases my workload, and the names of these folders are meaningless to my workflow.

My current workaround for this is reading the names of these folders (order-ids) one by one, make a GET request to https://developers.planet.com/apis/orders/reference/#tag/Orders/operation/getOrder, retrieve the order name from the response, and rename the folder. This is a cumbersome four-step process.

Proposed Solution In this line https://github.com/planetlabs/planet-client-python/blob/74e8b77af6c9c33b7a8dc85f57eacfe226eb6b63/planet/clients/orders.py#L233 we, have an option of filename. This should be the order_name. Additionally, in this line https://github.com/planetlabs/planet-client-python/blob/74e8b77af6c9c33b7a8dc85f57eacfe226eb6b63/planet/clients/orders.py#L264 we do have the option of giving an argument to the function, which is 'order_id' currently. If this changes to 'order_name', it will be better, because 'order_id' argument is read by this line https://github.com/planetlabs/planet-client-python/blob/74e8b77af6c9c33b7a8dc85f57eacfe226eb6b63/planet/clients/orders.py#L257 which saves the folder ultimately.

Describe alternatives you've considered

Additional context One of my customers complained that they can't use SDK because the final orders are saved in a folder/zipfile as order_ids, and they can't manually read each ID, copy it, search for it in Explorer, by opening each order one by one and comparing. Thus I created a script that could automate for them, but this creates additional load on Planet's servers, thus increasing cost. If we have SDK in-built solution, it will be good for the customer.

aayushmalik avatar Jul 19 '23 08:07 aayushmalik

@aayushmalik you've described the situation well and it seems sensible to me. What you're looking for is much like this zip delivery feature that exists in the Orders API, but not Tasking API, right? https://developers.planet.com/apis/orders/delivery/#whole-order-zipping.

sgillies avatar Jul 19 '23 17:07 sgillies

@sgillies, thanks for sharing this. Actually not, this isn't what I would like to have.

What you shared saves the files in following format

1b36c36c-8965-4e6f-9eef-ee9694f3d69c/per-order-zipped-order_1b36c36c-8965-4e6f-9eef-ee9694f3d69c.zip 1b36c36c-8965-4e6f-9eef-ee9694f3d69c/manifest.json

Which doesn't solve my problem as the parent folder is still named as order_id.

I would want a single zip file which is saved like this

per-order-zipped-order_1b36c36c-8965-4e6f-9eef-ee9694f3d69c.zip

That is to say, a single file that contains everything pertaining to an order, and inside this zip file, I can have manifest.json instead of outside. And the name of the zip_file should be order_name.

aayushmalik avatar Jul 20 '23 03:07 aayushmalik

@aayushmalik ah, ok, got it. A completed order carries one or more pairs of download links and names (one for the manifest, the other(s) for the assets or zip files). Overriding the API-suggested names won't be difficult.

I just now did a "single-archive" zip order and see that the manifest.json is included in it. Does that solve your manifest requirement?

unzip -l file.zip 
Archive:  file.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      979  2023-07-20 14:59   PSScene/20230701_170205_84_24bb_metadata.json
556107910  2023-07-20 14:59   PSScene/20230701_170205_84_24bb_3B_AnalyticMS_SR.tif
    10292  2023-07-20 14:59   PSScene/20230701_170205_84_24bb_3B_AnalyticMS_metadata.xml
  9021348  2023-07-20 14:59   PSScene/20230701_170205_84_24bb_3B_udm2.tif
      977  2023-07-20 14:59   PSScene/20230701_170201_13_24bb_metadata.json
567878783  2023-07-20 14:59   PSScene/20230701_170201_13_24bb_3B_AnalyticMS_SR.tif
    10285  2023-07-20 14:59   PSScene/20230701_170201_13_24bb_3B_AnalyticMS_metadata.xml
 11476548  2023-07-20 14:59   PSScene/20230701_170201_13_24bb_3B_udm2.tif
     8016  2023-07-20 14:59   PSScene/20230701_170201_13_24bb.json
     8020  2023-07-20 14:59   PSScene/20230701_165720_74_242d.json
     8016  2023-07-20 14:59   PSScene/20230701_165718_58_242d.json
     8015  2023-07-20 14:59   PSScene/20230701_170203_49_24bb.json
     8013  2023-07-20 14:59   PSScene/20230701_165714_43_242d.json
     8019  2023-07-20 14:59   PSScene/20230701_170205_84_24bb.json
     1692  2023-07-20 14:59   PSScene/PSScene_collection.json
      373  2023-07-20 14:59   catalog.json
     8014  2023-07-20 14:59   PSScene/20230701_165716_60_242d.json
     8015  2023-07-20 14:59   PSScene/20230701_170158_78_24bb.json
      980  2023-07-20 14:59   PSScene/20230701_165720_74_242d_metadata.json
477101816  2023-07-20 14:59   PSScene/20230701_165720_74_242d_3B_AnalyticMS_SR.tif
    10292  2023-07-20 14:59   PSScene/20230701_165720_74_242d_3B_AnalyticMS_metadata.xml
  8320240  2023-07-20 14:59   PSScene/20230701_165720_74_242d_3B_udm2.tif
      975  2023-07-20 14:59   PSScene/20230701_165716_60_242d_metadata.json
480889698  2023-07-20 14:59   PSScene/20230701_165716_60_242d_3B_AnalyticMS_SR.tif
    10292  2023-07-20 14:59   PSScene/20230701_165716_60_242d_3B_AnalyticMS_metadata.xml
  7158738  2023-07-20 14:59   PSScene/20230701_165716_60_242d_3B_udm2.tif
      974  2023-07-20 14:59   PSScene/20230701_165714_43_242d_metadata.json
482393449  2023-07-20 14:59   PSScene/20230701_165714_43_242d_3B_AnalyticMS_SR.tif
    10291  2023-07-20 14:59   PSScene/20230701_165714_43_242d_3B_AnalyticMS_metadata.xml
  6607010  2023-07-20 14:59   PSScene/20230701_165714_43_242d_3B_udm2.tif
      977  2023-07-20 14:59   PSScene/20230701_165718_58_242d_metadata.json
484352390  2023-07-20 14:59   PSScene/20230701_165718_58_242d_3B_AnalyticMS_SR.tif
    10291  2023-07-20 15:00   PSScene/20230701_165718_58_242d_3B_AnalyticMS_metadata.xml
  8193928  2023-07-20 15:00   PSScene/20230701_165718_58_242d_3B_udm2.tif
      975  2023-07-20 15:00   PSScene/20230701_170158_78_24bb_metadata.json
554095482  2023-07-20 15:00   PSScene/20230701_170158_78_24bb_3B_AnalyticMS_SR.tif
    10293  2023-07-20 15:00   PSScene/20230701_170158_78_24bb_3B_AnalyticMS_metadata.xml
  9168706  2023-07-20 15:00   PSScene/20230701_170158_78_24bb_3B_udm2.tif
      978  2023-07-20 15:00   PSScene/20230701_170203_49_24bb_metadata.json
569476431  2023-07-20 15:00   PSScene/20230701_170203_49_24bb_3B_AnalyticMS_SR.tif
    10293  2023-07-20 15:00   PSScene/20230701_170203_49_24bb_3B_AnalyticMS_metadata.xml
 10730538  2023-07-20 15:00   PSScene/20230701_170203_49_24bb_3B_udm2.tif
    15114  2023-07-20 15:00   manifest.json
---------                     -------
4243144466                     43 files

sgillies avatar Jul 20 '23 21:07 sgillies

Location link and name example:

      {
        "delivery": "success",
        "expires_at": "2023-07-21T21:23:19.817Z",
        "location": "https://api.planet.com/compute/ops/download/?token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODk5NzQ1OTksInN1YiI6ImY5RDU3dGhQaFVuQWgwWldsYUNWblpTY256WU1WakJBOGJkZjNoVmV3eUUzTGF6RFN1ekt6Z2xadWk5bzJaRzhDYVlRcUtHTDh1UjVwTHZId0xlUlZ3PT0iLCJ0b2tlbl90eXBlIjoiZG93bmxvYWQtYXNzZXQtc3RhY2siLCJhb2kiOiIiLCJhc3NldHMiOlt7Iml0ZW1fdHlwZSI6IiIsImFzc2V0X3R5cGUiOiIiLCJpdGVtX2lkIjoiIn1dLCJ1cmwiOiJodHRwczovL3N0b3JhZ2UuZ29vZ2xlYXBpcy5jb20vY29tcHV0ZS1vcmRlcnMtbGl2ZS82MDFlOGE4Zi0yODE1LTQ2MTUtOTJhZS00ODRiYzJkOTVkOTMvVGVzdF9zaW5nbGVfYXJjaGl2ZS02MDFlOGE4Zi0yODE1LTQ2MTUtOTJhZS00ODRiYzJkOTVkOTMuemlwP1gtR29vZy1BbGdvcml0aG09R09PRzQtUlNBLVNIQTI1Nlx1MDAyNlgtR29vZy1DcmVkZW50aWFsPWNvbXB1dGUtZ2NzLXN2Y2FjYyU0MHBsYW5ldC1jb21wdXRlLXByb2QuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20lMkYyMDIzMDcyMCUyRmF1dG8lMkZzdG9yYWdlJTJGZ29vZzRfcmVxdWVzdFx1MDAyNlgtR29vZy1EYXRlPTIwMjMwNzIwVDIxMjMxOVpcdTAwMjZYLUdvb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articulate my needs clearly, but I don't want a folder which is named as order_id. Instead I just need a zip file with its name as order_name.

For example, currently after the whole operation is over, I get ABC_ORDER_ID/ABC_XYZ.zip, I don't want this.

I just want ABC_XYZ.zip.

Currently, I am doing this manually using mv command. For example mv ./orders/*/* ./orders What this essentially does is go inside each of the folders that are names as order_id, take out the zip file from there and put it in the main orders directory.

Please let me know if you need further clarifications on this.

aayushmalik avatar Jul 21 '23 07:07 aayushmalik

For example, currently after the whole operation is over, I get ABC_ORDER_ID/ABC_XYZ.zip, I don't want this.

I just want ABC_XYZ.zip.

@aayushmalik right, I get it. I'm making notes here for the developer who will implement the new feature and am pointing out that 1) "ABC_ORDER_ID/ABC_XYZ.zip" is the name suggested by the Orders API, and 2) we can override this name as needed instead of always accepting the suggestion as we do now.

sgillies avatar Jul 21 '23 14:07 sgillies

This ticket needs to be coordinated with https://github.com/planetlabs/planet-client-python/issues/974

JuLeeAtPlanet avatar Jul 31 '23 18:07 JuLeeAtPlanet