Skip to content

Commit

Permalink
add config override feature for flask run
Browse files Browse the repository at this point in the history
  • Loading branch information
atwang16 committed Oct 21, 2024
1 parent d5b82fd commit 679cbc5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ MANIFEST.in
*.png
scenestate*.json
shap_e_model_cache/

*.json
4 changes: 1 addition & 3 deletions libsg/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ def generate_scene():
format_ = request.json.get("format", "STK")
config = request.json.get("config", {})
scene_spec = SceneSpec(type=SceneType(type_), input=input_, format=format_)
out = scene_generate_api(scene_spec, **config)
print(out)
return out
return scene_generate_api(scene_spec, **config)


@app.route("/object/add", methods=["POST"])
Expand Down
11 changes: 9 additions & 2 deletions libsg/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# from omegaconf import OmegaConf
import json
import os

from hydra import compose, initialize

if os.path.exists("overrides.json"):
with open("overrides.json", "r") as f:
overrides_raw = json.load(f)
overrides = [f"{k}={v}" for k, v in overrides_raw.items()]

initialize(version_base=None, config_path='../conf')
config = compose('config.yaml')
config = compose('config.yaml', overrides=overrides)
# print(OmegaConf.to_container(config))

0 comments on commit 679cbc5

Please sign in to comment.