diff options
author | Arun Isaac | 2024-01-02 13:22:23 +0000 |
---|---|---|
committer | Arun Isaac | 2024-01-02 13:40:56 +0000 |
commit | ee27a5b0e0abcb08ce54fd41a5098522a812f8bd (patch) | |
tree | 5c220a41adfd37ea06893a6c518c971c98eccb96 | |
parent | 70c4201b332e0e2c0d958428086512f291469b87 (diff) | |
download | genenetwork2-ee27a5b0e0abcb08ce54fd41a5098522a812f8bd.tar.gz |
Consistently use GN_VERSION from app config.
GN_VERSION is set in the configuration file and read into the app
config dictionary. Use that instead of re-reading from the etc/VERSION
file.
* gn2/utility/tools.py (gn_version): Delete function.
(GN_VERSION): Delete variable.
* gn2/wqflask/metadata_edits.py (display_phenotype_metadata,
display_probeset_metadata, show_history): Use GN_VERSION in app
config.
* gn2/wqflask/views.py: Do not import GN_VERSION from
gn2.utility.tools.
(handle_generic_exceptions, index_page.__render__, submit_trait_form):
Use GN_VERSION in app config.
-rw-r--r-- | gn2/utility/tools.py | 11 | ||||
-rw-r--r-- | gn2/wqflask/metadata_edits.py | 6 | ||||
-rw-r--r-- | gn2/wqflask/views.py | 7 |
3 files changed, 6 insertions, 18 deletions
diff --git a/gn2/utility/tools.py b/gn2/utility/tools.py index 7adf8e8f..159643d3 100644 --- a/gn2/utility/tools.py +++ b/gn2/utility/tools.py @@ -264,18 +264,7 @@ def gn_version_repo_info(root_dir): except: return "" -def gn_version(): - """Compute and return the version of the application.""" - hostname = socket.gethostname() - basedir = Path(__file__).absolute().parent.parent.parent - with open(Path(basedir, "etc", "VERSION"), encoding="utf8") as version_file: - version_contents = version_file.read().strip() - base_version = f"{hostname}:{basedir.name}:{version_contents}" - repo_info = gn_version_repo_info(basedir) - return f"{base_version}-{repo_info}" if bool(repo_info) else base_version - # Cached values -GN_VERSION = gn_version() HOME = get_setting('HOME') SERVER_PORT = get_setting('SERVER_PORT') WEBSERVER_MODE = get_setting('WEBSERVER_MODE') diff --git a/gn2/wqflask/metadata_edits.py b/gn2/wqflask/metadata_edits.py index b9514b35..6bcbd648 100644 --- a/gn2/wqflask/metadata_edits.py +++ b/gn2/wqflask/metadata_edits.py @@ -134,7 +134,7 @@ def display_phenotype_metadata(dataset_id: str, name: str): dataset_id=dataset_id, name=name, resource_id=request.args.get("resource-id"), - version=get_setting("GN_VERSION"), + version=current_app.config.get("GN_VERSION"), dataset_name=request.args["dataset_name"]) @@ -158,7 +158,7 @@ def display_probeset_metadata(name: str): probeset_id=_d["probeset"]["id_"], name=name, resource_id=request.args.get("resource-id"), - version=get_setting("GN_VERSION"), + version=current_app.config.get("GN_VERSION"), dataset_name=request.args["dataset_name"], sample_list=sample_list, sample_data=sample_data @@ -758,7 +758,7 @@ def show_history(dataset_id: str = "", name: str = ""): return render_template( "edit_history.html", diff={key: set(val) for key,val in diff_data_}, - version=get_setting("GN_VERSION"), + version=current_app.config.get("GN_VERSION"), ) def __authorised_p__(dataset_name, trait_name): diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index 4f636ebc..80199ecb 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -90,7 +90,6 @@ from gn2.utility.tools import USE_REDIS from gn2.utility.tools import REDIS_URL from gn2.utility.tools import GN_SERVER_URL from gn2.utility.tools import GN3_LOCAL_URL -from gn2.utility.tools import GN_VERSION from gn2.utility.tools import JS_TWITTER_POST_FETCHER_PATH from gn2.utility.tools import JS_GUIX_PATH from gn2.utility.helper_functions import get_species_groups @@ -143,7 +142,7 @@ def handle_generic_exceptions(e): resp = make_response(render_template("error.html", message=err_msg, stack={formatted_lines}, error_image=animation, - version=GN_VERSION)) + version=current_app.config.get("GN_VERSION"))) resp.set_cookie(err_msg[:32], animation) return resp @@ -157,7 +156,7 @@ def no_access_page(): def index_page(): anon_id = session_info()["anon_id"] def __render__(colls): - return render_template("index_page.html", version=GN_VERSION, + return render_template("index_page.html", version=current_app.config.get("GN_VERSION"), gn_server_url=GN_SERVER_URL, anon_collections=( colls if user_logged_in() else []), @@ -380,7 +379,7 @@ def submit_trait_form(): "submit_trait.html", species_and_groups=species_and_groups, gn_server_url=GN_SERVER_URL, - version=GN_VERSION) + version=current_app.config.get("GN_VERSION")) @app.route("/create_temp_trait", methods=('POST',)) |