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

GCBM Simulation API and End-Points for upload #152

Closed
wants to merge 2 commits into from

Conversation

ankitaS11
Copy link
Contributor

Pull Request Template

Description

This PR introduces a GCBMSimulation class, and end-point upload for uploading files for categories: disturbance, classifiers, miscellaneous (disturbance is kept optional). The way to add a file using GCBMSimulation is:

gcbm = GCBMSimulation()
gcbm.add_file(“classifiers/<filename>.tiff”)

And it will generate the JSON file for you, in templates/config/ folder.

The API also makes sure to raise an error for missing categories once it’s done. For example, if you passed only disturbance and classifier files using curl -F command, it will raise an error like:

{
  "error": "Missing files for categories: [‘disturbance’, 'miscellaneous', 'config_files', 'input'], they are required for the simulation to run"
}

So that the user is aware which categories they missed. For this purpose, I created an enum REQUIRED and corresponding to each category we have a “YES/NO” (REQUIRED.yes, REQUIRED.no) - so, if in the future, a category’s “required” value is changed, we can just change it in the app.py to REQUIRED.<new_value(yes/no)>.

To support any new categories, it should be straight forward:

class GCBMClassifiersList(GCBMList):
    def __init__(self, files, config):
        category = "classifiers"
        self.files = files  # empty list
        self.config = config  # empty dict
        super().__init__(category=category)

I took a look at the expected JSON files, I was able to add: cell<Lat/Long>Size, block<Lat/Long>size, tile<Lat/Long>Size, nodata, layer_type, layer_data to the JSON file. For other data in “attributes” key, like “disturbance_type”, “transition” etc. - those need to be hard-coded for each year file?

TODOs:

  • Add tests for the end-points and GCBMSimulation class
  • Add support for config files

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • 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 not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please see the README for any instructions on how to run the end-point. Tests will be added once all the categories have been added.

Additional Context (Please include any Screenshots/gifs if relevant)

...

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • I have tagged the reviewers in a comment below incase my pull request is ready for a review
  • I have signed the commit message to agree to Developer Certificate of Origin (DCO) (to certify that you wrote or otherwise have the right to submit your contribution to the project.) by adding "--signoff" to my git commit command.

Thanks!

Cc: @aornugent , @Namyalg, @padmajabhol, @SanjaySinghRajpoot @YashKandalkar

@github-actions github-actions bot added the GCBM label Jul 14, 2022
@ankitaS11 ankitaS11 marked this pull request as draft July 14, 2022 17:00
@aornugent aornugent mentioned this pull request Jul 31, 2022
@aornugent
Copy link
Contributor

Closed in favour of #163

@aornugent aornugent closed this Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants