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

[BUG] Keep python-API stable between 1 and >1 results #556

Open
SlowMo24 opened this issue Jan 24, 2025 · 1 comment
Open

[BUG] Keep python-API stable between 1 and >1 results #556

SlowMo24 opened this issue Jan 24, 2025 · 1 comment
Labels

Comments

@SlowMo24
Copy link

Describe the bug

SentinelHubRequest.get_data function return value differs in shape depending on the length of the responses input array.

It is a list of arrays, if one response is specified but a list of dicts, if two or more responses are specified. This change in API mimics the return value of the online-API (a response.tiff for one result and a response.tar containting tiffs for more than one) but is confusing on the python-end.

To Reproduce

Steps to reproduce the behavior:

Assume the following setup:

Details

from sentinelhub import SentinelHubRequest, DataCollection, MimeType, SHConfig, BBox, CRS

evalscript_true_color = """
    //VERSION=3

    function setup() {
        return {
            input: [{
                bands: ["B02", "B03", "B04"]
            }],
            output: [{
                id: "default",
                bands: 3
            },{
                id: "other",
                bands: 3
            }]
        };
    }

    function evaluatePixel(sample) {
        return {"default":[sample.B04, sample.B03, sample.B02],
        "other":[sample.B04, sample.B03, sample.B02]};
    }
"""
input_data = [
    SentinelHubRequest.input_data(
        data_collection=DataCollection.SENTINEL2_L1C,
        time_interval=("2020-06-12", "2020-06-13"),
    ),
]
bbox = BBox((
    13.82,
    45.85,
    13.83,
    45.86
), crs=CRS("4326"))
config=SHConfig(your-credentials)

  1. request data with one output
responses = [SentinelHubRequest.output_response("default", MimeType.PNG)]

request = SentinelHubRequest(
    evalscript=evalscript_true_color,
    input_data=input_data,
    responses=responses,
    bbox=bbox,
    config=config,
)

data_one_response = request.get_data()[0]
  1. request data with two outputs
responses = [SentinelHubRequest.output_response("default", MimeType.PNG),
             SentinelHubRequest.output_response("other", MimeType.PNG)]

request = SentinelHubRequest(
    evalscript=evalscript_true_color,
    input_data=input_data,
    responses=responses,
    bbox=bbox,
    config=config,
)

data_two_responses = request.get_data()[0]
  1. see that the API to access the data has changed
type(data_one_response) #ndarray
type(data_two_responses) #dict

actual_data = data_two_responses["original.tif"]

Expected behavior

The API should not change between the two examples. I.e. I suggest the retrieval from the first example would happen via

actual_data = data_one_response["original.tif"]

Environment

  • Python 3.11.11
  • sentinelhub 3.11.1

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Browser: Firefox
  • Version 134.0.2
@SlowMo24 SlowMo24 added the bug label Jan 24, 2025
@zigaLuksic
Copy link
Collaborator

I personally agree with you that such a dynamic output is suboptiomal, however such changes would be very code-breaking for users. Currently there are no large changes planned in the near future, but we will keep the issue open, so that it is taken into consideration in the next large release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants