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

Add analysis data request with AOIs #699

Merged
merged 15 commits into from
Oct 20, 2023

Conversation

danielfdsilva
Copy link
Collaborator

@danielfdsilva danielfdsilva commented Oct 12, 2023

Implements the analysis flow, using the aois drawn on the map, requests data and displays it on the chart.
Also adds support for each dataset to have independent customizable metrics.

@netlify
Copy link

netlify bot commented Oct 12, 2023

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit c46bf5d
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/65315e49736ad9000815411b
😎 Deploy Preview https://deploy-preview-699--veda-ui.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@j08lue
Copy link
Contributor

j08lue commented Oct 13, 2023

Copy link
Contributor

@nerik nerik left a comment

Choose a reason for hiding this comment

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

Looking good so far. The analysis state should probably be reset on deleting polygons. We aslo should migrate at some point the logic implemented here to limit the potentially very high number of stac items requested.

const dataset = useAtomValue(datasetAtom);
const datasetStatus = dataset.status;

const [, setAnalysis] = useTimelineDatasetAnalysis(datasetAtom);
Copy link
Contributor

Choose a reason for hiding this comment

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

You could have useTimelineDatasetAnalysis only return a setter (useSetAtom) and simplify this:

Suggested change
const [, setAnalysis] = useTimelineDatasetAnalysis(datasetAtom);
const setAnalysis = useTimelineDatasetAnalysis(datasetAtom);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's a good point. I was trying to be consistent with the other useTimelineDataset*, like useTimelineDatasetVisibility or useTimelineDatasetSettings where they return getters and setters. You think it is not needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

The consistency argument is a reasonable one, but in that case why not just returning the atoms themselves?

export function useTimelineDatasetAnalysisAtom() {
  const analysisAtom = ...

  return analysisAtom;
}
Suggested change
const [, setAnalysis] = useTimelineDatasetAnalysis(datasetAtom);
const setAnalysis = useSetAtom(useTimelineDatasetAnalysisAtom(datasetAtom));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was trying to avoid this function train and make the hook usage more direct. Nevertheless I'm not set on this format and I'm not opposed to changing it. Do you have a preference?

Copy link
Collaborator

@hanbyul-here hanbyul-here left a comment

Choose a reason for hiding this comment

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

+1 on @nerik 's comment that we need to put a guardrail to prevent excessive amount of requests.

When I was checking, Nightlight dataset was returning errors on some of the items. (Not sure if it is something that can be reproduced consistently or a hiccup. Bonus point if you can shed an insight to test without depending on actual response! ) And a dataset list item doesn't reflect the error, gets stuck at the loading state. (As far as I can read, it seems error state gets washed out from the other request's loading state?)
Screen Shot 2023-10-16 at 3 04 49 PM

@danielfdsilva
Copy link
Collaborator Author

@hanbyul-here You unearthed quite an interesting bug. I think I fixed the problem and now when there's an error you'll get the proper message and the loading will stop. You'll also be able to retry the analysis which was not yet implemented 😅.

As for Nightlights: it sometimes errors seemingly randomly. It seems that if there are a lot of requests it errors (although we're throttling at 15 simultaneous). Perhaps it has to do with api load or something. @ividito any debugging we can do here?

@danielfdsilva danielfdsilva force-pushed the feature/analysis-requests branch from b679001 to d86ff7e Compare October 17, 2023 16:32
@hanbyul-here
Copy link
Collaborator

I am a bit confused that the pr is still in draft state. But giving approval since the changes I requested were made. 👍

@danielfdsilva
Copy link
Collaborator Author

@hanbyul-here Thank you. It is Draft since still need to address the message with @ricardoduplos . But the functionality can be reviewed :)

@ividito
Copy link

ividito commented Oct 19, 2023

As for Nightlights: it sometimes errors seemingly randomly. It seems that if there are a lot of requests it errors (although we're throttling at 15 simultaneous). Perhaps it has to do with api load or something. @ividito any debugging we can do here?

I looked into this and it looks like a handful of nightlights "regions" will cause excessive loading times, which can cascade into the service timing out. I think the newest version of the preview handles this a bit better - I still see longer loading times in some areas, but it's no longer causing an actual error for me.

This is probably something we can correct on the backend - I'll make an issue to track this in that repo.

@danielfdsilva
Copy link
Collaborator Author

@ricardoduplos Messages implemented according to the design. Please have a look!

Copy link
Contributor

@ricardoduplos ricardoduplos 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!

@danielfdsilva danielfdsilva marked this pull request as ready for review October 20, 2023 13:08
@danielfdsilva danielfdsilva merged commit ff15c00 into feature/exploration Oct 20, 2023
8 checks passed
@danielfdsilva danielfdsilva deleted the feature/analysis-requests branch October 20, 2023 13:09
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.

6 participants