OpenWaterFoundation / owf-app-infomapper-builder-ng

Open Water Foundation web application to build an InfoMapper configuration
GNU General Public License v3.0
0 stars 0 forks source link

Need simple Python app to simulate S3 during builder development #9

Open smalers opened 1 year ago

smalers commented 1 year ago

In order to simulate the production system during development, it would be useful to have a local web service application that can save files to the local file system. This will be helpful for development to prototype the solution and while we are figuring out the AWS implementation. It is hopefully also faster than using S3/CloudFront, especially to avoid invalidations, and a local tool will avoid AWS charges, in particular invalidations, which has a relatively low free tier threshold.

For example, run a local web server and web services that accepts a PUT or POST http request with a file attachment and location to save, similar to an S3 copy. The local location can be set up to be similar to that on a production system, which would be the same or similar as the folder structure under the InfoMapper assets. We can finalize the folder structure as we work through the implementation.

I found this simple Python Flask application and if this is not OK then maybe there is something similar.

It would work something like this:

  1. Python application:
    1. Create in a folder in the Builder repo, separate from Angular work, such as s3-mock-server?
    2. Probably need to run on a specific port and can figure out the URL routing. Start the server with a bash script.
    3. The service will need to accept the file as payload and maybe the service query parameter indicates the where to save the file?
  2. In the InfoMapper Builder:
    1. Have some configuration that knows to use the local server.
    2. When the "save to S3" button is pressed in the builder, the production code will do an S3 API request to save a file to S3, whereas the mock server will save to the local file system.
  3. In the InfoMapper:
    1. The InfoMapper will be run locally and will somehow need to know how to use the files from 2 above.
    2. If it is listening for file changes, it will detect the local file change and reload.
    3. To increase efficiency, this might be where saving cookies to remember application state is useful so that changes don't require renavigating to the same state.

For all of the above, the software needs to be flexible enough to work in local mode and also production S3 mode. Production mode will be enabled over time and can be tested in addition to testing in local mode.