generated from moja-global/Import-Me
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Namyalg
merged 6 commits into
moja-global:master
from
khanjasir90:feat/creat-endpoint-to-return-json
Oct 2, 2022
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9bdd967
feat: added endpoint to return .json for the input .tiff file
khanjasir90 2501aa4
feat: updated endpoint with specified changes and some constraints
khanjasir90 3f2dcc2
feat: formatted code with black
khanjasir90 7b34b0a
Merge branch 'master' into feat/creat-endpoint-to-return-json
Namyalg 0cee49a
updated minor typos
khanjasir90 e5424ff
Merge branch 'feat/creat-endpoint-to-return-json' of https://github.c…
khanjasir90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,7 +323,7 @@ def gcbm_dynamic(): | |
responses: | ||
200: | ||
parameters: | ||
- in: body | ||
- in: body | ||
name: title | ||
required: true | ||
schema: | ||
|
@@ -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 + " does'nt 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 + " does'nt exists"}, 400 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change to |
||
|
||
# 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") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to
doesn't