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

feat: added endpoint to return .json for the input .tiff file #185

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion local/rest_api_gcbm/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def gcbm_dynamic():
responses:
200:
parameters:
- in: body
- in: body
name: title
required: true
schema:
Expand All @@ -350,6 +350,56 @@ def gcbm_dynamic():
return {"status": "Run started"}, 200


@app.route("/gcbm/getConfig", methods=["POST"])
def getConfig():
"""
Return .json for the input .tiff files
---
tags:
- gcbm
responses:
200:
parameters:
- in: body
name: title
required: true
schema:
type: string
description: Name of the Simulation
name: file_name
required: true
schema:
type: string
description: Name of the File
"""
# Default title = Simulation
title = request.form.get("title").strip()
file_name = request.form.get("file_name").strip()
input_dir = f"{os.getcwd()}/input/{title}"

# check if title is empty
if title == "":
return {"error": "No Simulation name specified"}, 400

# check if file_name is empty
if file_name == "":
return {"error": "No file name specified"}, 400

# Check if simulation exists or not
if not os.path.exists(f"{input_dir}"):
return {"error": "Simulation with the name " + title + " doesn't exists"}, 400

input_dir_file = f"{input_dir}/{file_name}.json"
# Check if file exists or not
if not os.path.exists(f"{input_dir_file}"):
return {"error": "File with name " + file_name + " doesn't exists"}, 400

# Return the json for the corresponding file name
file_obj = open(f"{input_dir_file}")
obj = json.load(file_obj)
return {"data": obj}, 200


def launch_run(title, input_dir):
s = time.time()
logging.debug("Starting run")
Expand Down