From 11f418b165cadd95fd2b181abdd41377523433e5 Mon Sep 17 00:00:00 2001 From: titavare Date: Fri, 22 Mar 2024 11:44:30 +0100 Subject: [PATCH 01/18] changed run_number flag to run_num to make it fit with automatic insertRun (when running) and added a foreignkey to RunNumberMeta to fit with oracle database --- runregistry-rest/api.py | 4 ++-- runregistry-rest/database.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index b60363d..f779d02 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -167,7 +167,7 @@ def get(self, runNum): print(f"Exception:{err_obj}") return flask.make_response(flask.jsonify({"Exception": f"{err_obj}"})) -# $ curl -u fooUsr:barPass -F "run_number=1000" -F "det_id=foo" -F "run_type=bar" -F "software_version=dunedaq-vX.Y.Z" -F "file=@sspconf.tar.gz" -X POST np04-srv-017:30015/runregistry/insertRun/ +# $ curl -u fooUsr:barPass -F "run_num=1000" -F "det_id=foo" -F "run_type=bar" -F "software_version=dunedaq-vX.Y.Z" -F "file=@sspconf.tar.gz" -X POST np04-srv-017:30015/runregistry/insertRun/ @api.resource("/runregistry/insertRun/") class insertRun(Resource): """ @@ -181,7 +181,7 @@ def post(self): local_file_name = None try: # Ensure form fields - run_number = flask.request.form.get("run_number") + run_number = flask.request.form.get("run_num") det_id = flask.request.form.get("det_id") run_type = flask.request.form.get("run_type") software_version = flask.request.form.get("software_version") diff --git a/runregistry-rest/database.py b/runregistry-rest/database.py index 8319003..79798ac 100644 --- a/runregistry-rest/database.py +++ b/runregistry-rest/database.py @@ -27,10 +27,11 @@ class RunRegistryMeta(db.Model): software_version = db.Column( 'software_version', db.String(40) ) + configs = db.relationship('RunRegistryConfigs', backref='meta') class RunRegistryConfigs(db.Model): run_number = db.Column( - 'run_number', db.Integer, primary_key=True, autoincrement=True, nullable=False + 'run_number', db.Integer, db.ForeignKey(RunRegistryMeta.run_number), primary_key=True, nullable=False ) configuration = db.Column( 'configuration', db.LargeBinary, nullable=False From eb029aefe88c271a8645555eb458081cce330ec3 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 9 Apr 2024 12:51:26 +0200 Subject: [PATCH 02/18] adding pool recycling to make sure oracle connection doesn't fail and more error checking for database connection errors --- runnumber-rest/api.py | 15 +++++++++++++-- runregistry-rest/api.py | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/runnumber-rest/api.py b/runnumber-rest/api.py index 231d192..9856cb9 100644 --- a/runnumber-rest/api.py +++ b/runnumber-rest/api.py @@ -19,7 +19,8 @@ import flask from flask_restful import Api, Resource from flask_sqlalchemy import SQLAlchemy -from sqlalchemy import func +from sqlalchemy import func, event +import re __all__ = ["app", "api", "db"] @@ -32,6 +33,7 @@ DEPLOYMENT_ENV=os.environ.get("DEPLOYMENT_ENV", "DEV"), RUN_START=int(os.getenv("RUN_START", "1000")), SQLALCHEMY_ECHO=False, + SQLALCHEMY_ENGINE_OPTIONS={"pool_pre_ping": True, "pool_recycle": 3600}, ) uri = app.config["SQLALCHEMY_DATABASE_URI"] @@ -46,6 +48,14 @@ PARSED_URI = urlparse(app.config["SQLALCHEMY_DATABASE_URI"]) DB_TYPE = PARSED_URI.scheme +@app.before_first_request +def register_event_handlers(): + @event.listens_for(db.engine, "handle_error") + def handle_exception(context): + if not context.is_disconnect and re.match( + r"^(?:DPI-1001|DPI-4011)", str(context.original_exception) + ): + context.is_disconnect = True # $ curl -u fooUsr:barPass -X GET np04-srv-021:30016//runnumber/get @api.resource("/runnumber/get") @@ -93,7 +103,8 @@ def get(self): run = RunNumber(rn=current_max_run) db.session.add(run) print(f"getNewtRunNumber: result {[current_max_run]}") - return flask.make_response(flask.jsonify([[[current_max_run]]])) + cnu = [name.upper() for name in column_names] + return flask.make_response(flask.jsonify(cnu, [[*result]])) except Exception as err_obj: print(f"Exception:{err_obj}") return flask.make_response(flask.jsonify({"Exception": f"{err_obj}"})) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index f779d02..7d4e540 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -20,7 +20,8 @@ from flask_caching import Cache from flask_restful import Api, Resource from flask_sqlalchemy import SQLAlchemy -from sqlalchemy import desc, func +from sqlalchemy import func, event +import re __all__ = ["app", "api", "db"] @@ -37,6 +38,7 @@ DEPLOYMENT_ENV=os.environ.get("DEPLOYMENT_ENV", "DEV"), RUN_START=int(os.getenv("RUN_START", "1000")), SQLALCHEMY_ECHO=False, + SQLALCHEMY_ENGINE_OPTIONS={"pool_pre_ping": True, "pool_recycle": 3600}, ) cache = Cache(app) @@ -53,6 +55,14 @@ PARSED_URI = urlparse(app.config["SQLALCHEMY_DATABASE_URI"]) DB_TYPE = PARSED_URI.scheme +@app.before_first_request +def register_event_handlers(): + @event.listens_for(db.engine, "handle_error") + def handle_exception(context): + if not context.is_disconnect and re.match( + r"^(?:DPI-1001|DPI-4011)", str(context.original_exception) + ): + context.is_disconnect = True def cache_key(): args = flask.request.args @@ -93,7 +103,8 @@ def get(self, runNum): result = list(result) column_names = RunRegistryMeta.__table__.columns.keys() column_names.remove('filename') #Don't like this but only way to stay consistent with Oracle - return flask.make_response(flask.jsonify(column_names, [[*result]])) + cnu = [name.upper() for name in column_names] + return flask.make_response(flask.jsonify(cnu, [[*result]])) except Exception as err_obj: print(f"Exception:{err_obj}") return flask.make_response(flask.jsonify({"Exception": f"{err_obj}"})) From 417975c4824174ac1d6328ed8255bdea677e5154 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 9 Apr 2024 12:54:27 +0200 Subject: [PATCH 03/18] forgot UpperCasing for one of the column names --- runregistry-rest/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index 7d4e540..355ff57 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -138,7 +138,8 @@ def get(self, amount): result = [list(row) for row in result] column_names = RunRegistryMeta.__table__.columns.keys() column_names.remove('filename') #Don't like this but only way to stay consistent with Oracle - return flask.make_response(flask.jsonify(column_names, [*result])) + cnu = [name.upper() for name in column_names] + return flask.make_response(flask.jsonify(cnu, [[*result]])) except Exception as err_obj: return flask.make_response(flask.jsonify({"Exception": f"{err_obj}"})) From b7a9b63f25e8622071d3a83ed4b42d349d2fe7e0 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 9 Apr 2024 16:30:27 +0200 Subject: [PATCH 04/18] column names in runnumber was wrong --- runnumber-rest/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runnumber-rest/api.py b/runnumber-rest/api.py index 9856cb9..894e5ea 100644 --- a/runnumber-rest/api.py +++ b/runnumber-rest/api.py @@ -103,8 +103,7 @@ def get(self): run = RunNumber(rn=current_max_run) db.session.add(run) print(f"getNewtRunNumber: result {[current_max_run]}") - cnu = [name.upper() for name in column_names] - return flask.make_response(flask.jsonify(cnu, [[*result]])) + return flask.make_response(flask.jsonify([[[current_max_run]]])) except Exception as err_obj: print(f"Exception:{err_obj}") return flask.make_response(flask.jsonify({"Exception": f"{err_obj}"})) From f0ad545bd4aa8971ac2fe7bc4bf1b72925482ca1 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 9 Apr 2024 16:48:04 +0200 Subject: [PATCH 05/18] some errors in imports --- runregistry-rest/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index 355ff57..db46550 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -20,7 +20,7 @@ from flask_caching import Cache from flask_restful import Api, Resource from flask_sqlalchemy import SQLAlchemy -from sqlalchemy import func, event +from sqlalchemy import desc, event import re __all__ = ["app", "api", "db"] From ed1488348b7e74ec49a5a7b7ec04e03e7702215a Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 9 Apr 2024 17:53:03 +0200 Subject: [PATCH 06/18] datetime not working --- runregistry-rest/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index db46550..2d2911e 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -45,7 +45,7 @@ db = SQLAlchemy(app) api = Api(app) -import datetime +from datetime import datetime import urllib from urllib.parse import urlparse From cee485f8517912ec23ca17a73eaef5dea9939fa7 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 9 Apr 2024 18:26:35 +0200 Subject: [PATCH 07/18] one final cosmetic change --- runregistry-rest/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index 2d2911e..17297f9 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -104,7 +104,7 @@ def get(self, runNum): column_names = RunRegistryMeta.__table__.columns.keys() column_names.remove('filename') #Don't like this but only way to stay consistent with Oracle cnu = [name.upper() for name in column_names] - return flask.make_response(flask.jsonify(cnu, [[*result]])) + return flask.make_response(flask.jsonify(cnu, [*result])) except Exception as err_obj: print(f"Exception:{err_obj}") return flask.make_response(flask.jsonify({"Exception": f"{err_obj}"})) From c870cd3dab0d2711dcbcb3d90946e2395639eca4 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 9 Apr 2024 18:30:51 +0200 Subject: [PATCH 08/18] changed wrong line --- runregistry-rest/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index 17297f9..96d4bf2 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -104,7 +104,7 @@ def get(self, runNum): column_names = RunRegistryMeta.__table__.columns.keys() column_names.remove('filename') #Don't like this but only way to stay consistent with Oracle cnu = [name.upper() for name in column_names] - return flask.make_response(flask.jsonify(cnu, [*result])) + return flask.make_response(flask.jsonify(cnu, [[*result]])) except Exception as err_obj: print(f"Exception:{err_obj}") return flask.make_response(flask.jsonify({"Exception": f"{err_obj}"})) @@ -139,7 +139,7 @@ def get(self, amount): column_names = RunRegistryMeta.__table__.columns.keys() column_names.remove('filename') #Don't like this but only way to stay consistent with Oracle cnu = [name.upper() for name in column_names] - return flask.make_response(flask.jsonify(cnu, [[*result]])) + return flask.make_response(flask.jsonify(cnu, [*result])) except Exception as err_obj: return flask.make_response(flask.jsonify({"Exception": f"{err_obj}"})) From 917d56c0e2ae3e390293391e04468aba46ad9e7b Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 9 Apr 2024 18:57:50 +0200 Subject: [PATCH 09/18] update stop time had been changed, changed it back --- runregistry-rest/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index 96d4bf2..a5c534e 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -245,8 +245,8 @@ def post(self): os.remove(local_file_name) -# $ curl -u fooUsr:barPass -X GET np04-srv-017:30015/runregistry/updatestop/ -@api.resource("/runregistry/updatestop/") +# $ curl -u fooUsr:barPass -X GET np04-srv-017:30015/runregistry/updateStopTime/ +@api.resource("/runregistry/updateStopTime/") class updateStopTimestamp(Resource): """ set and record the stop time for the run into the database From 822d3095f21fb421738073dfef8b106795eada59 Mon Sep 17 00:00:00 2001 From: titavare Date: Wed, 10 Apr 2024 23:25:30 +0100 Subject: [PATCH 10/18] testing new datetime --- runregistry-rest/api.py | 4 ++-- runregistry-rest/database.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index a5c534e..f413a7d 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -45,7 +45,7 @@ db = SQLAlchemy(app) api = Api(app) -from datetime import datetime +import datetime as dt import urllib from urllib.parse import urlparse @@ -260,7 +260,7 @@ def get(self, runNum): run = None with db.session.begin(): run = db.session.query(RunRegistryMeta).filter_by(run_number=runNum).one() - run.stop_time = datetime.now() + run.stop_time = dt.datetime.now(dt.UTC).replace(tzinfo=None) print(f"updateStopTimestamp: result {[run.start_time, run.stop_time]}") return flask.make_response(flask.jsonify([[[run.start_time, run.stop_time]]])) except Exception as err_obj: diff --git a/runregistry-rest/database.py b/runregistry-rest/database.py index 79798ac..7590b6c 100644 --- a/runregistry-rest/database.py +++ b/runregistry-rest/database.py @@ -1,4 +1,4 @@ -from datetime import datetime +import datetime as dt from api import db @@ -10,7 +10,7 @@ class RunRegistryMeta(db.Model): 'run_number', db.Integer, primary_key=True, autoincrement=True, nullable=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=datetime.now + 'start_time', db.TIMESTAMP(6), nullable=False, default=dt.datetime.now(dt.UTC).replace(tzinfo=None) ) stop_time = db.Column( 'stop_time', db.TIMESTAMP(6), nullable=True From f3e0a1ab0a962f4bb5f13c3022fc747af84d9474 Mon Sep 17 00:00:00 2001 From: titavare Date: Wed, 10 Apr 2024 23:41:33 +0100 Subject: [PATCH 11/18] testing new datetime because previous one failed --- runregistry-rest/api.py | 2 +- runregistry-rest/database.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index f413a7d..2a5a5aa 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -260,7 +260,7 @@ def get(self, runNum): run = None with db.session.begin(): run = db.session.query(RunRegistryMeta).filter_by(run_number=runNum).one() - run.stop_time = dt.datetime.now(dt.UTC).replace(tzinfo=None) + run.stop_time = dt.datetime.utcnow print(f"updateStopTimestamp: result {[run.start_time, run.stop_time]}") return flask.make_response(flask.jsonify([[[run.start_time, run.stop_time]]])) except Exception as err_obj: diff --git a/runregistry-rest/database.py b/runregistry-rest/database.py index 7590b6c..1a3de3c 100644 --- a/runregistry-rest/database.py +++ b/runregistry-rest/database.py @@ -10,7 +10,7 @@ class RunRegistryMeta(db.Model): 'run_number', db.Integer, primary_key=True, autoincrement=True, nullable=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=dt.datetime.now(dt.UTC).replace(tzinfo=None) + 'start_time', db.TIMESTAMP(6), nullable=False, default=dt.datetime.utcnow ) stop_time = db.Column( 'stop_time', db.TIMESTAMP(6), nullable=True From de5963c5b443b9cdecdf82996e2876dfb143076e Mon Sep 17 00:00:00 2001 From: titavare Date: Wed, 10 Apr 2024 23:45:03 +0100 Subject: [PATCH 12/18] changed it on runnumber too --- runnumber-rest/api.py | 2 +- runnumber-rest/database.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runnumber-rest/api.py b/runnumber-rest/api.py index 894e5ea..d4642a2 100644 --- a/runnumber-rest/api.py +++ b/runnumber-rest/api.py @@ -124,7 +124,7 @@ def get(self, runNum): run = None with db.session.begin(): run = db.session.query(RunNumber).filter_by(rn=runNum).one() - run.stop_time = datetime.now() + run.stop_time = datetime.utcnow() print(f"updateStopTimestamp: result {[run.start_time, run.stop_time]}") return flask.make_response(flask.jsonify([[[run.start_time, run.stop_time]]])) except Exception as err_obj: diff --git a/runnumber-rest/database.py b/runnumber-rest/database.py index 7d6b107..cbfc656 100644 --- a/runnumber-rest/database.py +++ b/runnumber-rest/database.py @@ -13,6 +13,6 @@ class RunNumber(db.Model): 'flag', db.Boolean, nullable=False, default=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=datetime.now + 'start_time', db.TIMESTAMP(6), nullable=False, default=datetime.utcnow ) stop_time = db.Column('stop_time', db.TIMESTAMP(6), nullable=True) From fe2e6badcf8f8aec4670133be1856cce97b89d32 Mon Sep 17 00:00:00 2001 From: titavare Date: Thu, 11 Apr 2024 00:19:58 +0100 Subject: [PATCH 13/18] date fix --- runnumber-rest/api.py | 4 ++-- runregistry-rest/api.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runnumber-rest/api.py b/runnumber-rest/api.py index d4642a2..1ad1d74 100644 --- a/runnumber-rest/api.py +++ b/runnumber-rest/api.py @@ -14,7 +14,7 @@ ] import os -from datetime import datetime +import datetime as dt import flask from flask_restful import Api, Resource @@ -124,7 +124,7 @@ def get(self, runNum): run = None with db.session.begin(): run = db.session.query(RunNumber).filter_by(rn=runNum).one() - run.stop_time = datetime.utcnow() + run.stop_time = dt.datetime.utcnow() print(f"updateStopTimestamp: result {[run.start_time, run.stop_time]}") return flask.make_response(flask.jsonify([[[run.start_time, run.stop_time]]])) except Exception as err_obj: diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index 2a5a5aa..cb4808c 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -260,7 +260,7 @@ def get(self, runNum): run = None with db.session.begin(): run = db.session.query(RunRegistryMeta).filter_by(run_number=runNum).one() - run.stop_time = dt.datetime.utcnow + run.stop_time = dt.datetime.utcnow() print(f"updateStopTimestamp: result {[run.start_time, run.stop_time]}") return flask.make_response(flask.jsonify([[[run.start_time, run.stop_time]]])) except Exception as err_obj: From 5c1cfd1982fd219dec7b515a381946b928e3e58e Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 16 Apr 2024 16:12:28 +0200 Subject: [PATCH 14/18] adding database time instead of utc --- runnumber-rest/api.py | 2 +- runnumber-rest/database.py | 4 +--- runregistry-rest/api.py | 4 ++-- runregistry-rest/database.py | 4 +--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/runnumber-rest/api.py b/runnumber-rest/api.py index 1ad1d74..9ace824 100644 --- a/runnumber-rest/api.py +++ b/runnumber-rest/api.py @@ -124,7 +124,7 @@ def get(self, runNum): run = None with db.session.begin(): run = db.session.query(RunNumber).filter_by(rn=runNum).one() - run.stop_time = dt.datetime.utcnow() + run.stop_time = func.now() print(f"updateStopTimestamp: result {[run.start_time, run.stop_time]}") return flask.make_response(flask.jsonify([[[run.start_time, run.stop_time]]])) except Exception as err_obj: diff --git a/runnumber-rest/database.py b/runnumber-rest/database.py index cbfc656..8bd6ddd 100644 --- a/runnumber-rest/database.py +++ b/runnumber-rest/database.py @@ -1,5 +1,3 @@ -from datetime import datetime - from api import db __all__ = ['RunNumber'] @@ -13,6 +11,6 @@ class RunNumber(db.Model): 'flag', db.Boolean, nullable=False, default=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=datetime.utcnow + 'start_time', db.TIMESTAMP(6), nullable=False, default=db.func.now ) stop_time = db.Column('stop_time', db.TIMESTAMP(6), nullable=True) diff --git a/runregistry-rest/api.py b/runregistry-rest/api.py index cb4808c..35e5bdd 100644 --- a/runregistry-rest/api.py +++ b/runregistry-rest/api.py @@ -20,7 +20,7 @@ from flask_caching import Cache from flask_restful import Api, Resource from flask_sqlalchemy import SQLAlchemy -from sqlalchemy import desc, event +from sqlalchemy import desc, event, func import re __all__ = ["app", "api", "db"] @@ -260,7 +260,7 @@ def get(self, runNum): run = None with db.session.begin(): run = db.session.query(RunRegistryMeta).filter_by(run_number=runNum).one() - run.stop_time = dt.datetime.utcnow() + run.stop_time = func.now() print(f"updateStopTimestamp: result {[run.start_time, run.stop_time]}") return flask.make_response(flask.jsonify([[[run.start_time, run.stop_time]]])) except Exception as err_obj: diff --git a/runregistry-rest/database.py b/runregistry-rest/database.py index 1a3de3c..d854b79 100644 --- a/runregistry-rest/database.py +++ b/runregistry-rest/database.py @@ -1,5 +1,3 @@ -import datetime as dt - from api import db __all__ = ['RunRegistryConfig', 'RunRegistryMeta'] @@ -10,7 +8,7 @@ class RunRegistryMeta(db.Model): 'run_number', db.Integer, primary_key=True, autoincrement=True, nullable=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=dt.datetime.utcnow + 'start_time', db.TIMESTAMP(6), nullable=False, default=db.func.now ) stop_time = db.Column( 'stop_time', db.TIMESTAMP(6), nullable=True From b46e8e0df2e03f9370946bdb658e036e9d1f3973 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 16 Apr 2024 16:21:31 +0200 Subject: [PATCH 15/18] figuring out if brackets are needed --- runnumber-rest/database.py | 2 +- runregistry-rest/database.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runnumber-rest/database.py b/runnumber-rest/database.py index 8bd6ddd..3356fbc 100644 --- a/runnumber-rest/database.py +++ b/runnumber-rest/database.py @@ -11,6 +11,6 @@ class RunNumber(db.Model): 'flag', db.Boolean, nullable=False, default=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=db.func.now + 'start_time', db.TIMESTAMP(6), nullable=False, default=db.func.now() ) stop_time = db.Column('stop_time', db.TIMESTAMP(6), nullable=True) diff --git a/runregistry-rest/database.py b/runregistry-rest/database.py index d854b79..40ce26d 100644 --- a/runregistry-rest/database.py +++ b/runregistry-rest/database.py @@ -8,7 +8,7 @@ class RunRegistryMeta(db.Model): 'run_number', db.Integer, primary_key=True, autoincrement=True, nullable=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=db.func.now + 'start_time', db.TIMESTAMP(6), nullable=False, default=db.func.now() ) stop_time = db.Column( 'stop_time', db.TIMESTAMP(6), nullable=True From dcbafdada0d4f8c1eb3f67c8ee4f8bda88802d87 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 16 Apr 2024 16:36:09 +0200 Subject: [PATCH 16/18] trying out more time fixes --- runnumber-rest/database.py | 4 ++-- runregistry-rest/database.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runnumber-rest/database.py b/runnumber-rest/database.py index 3356fbc..23fb9ce 100644 --- a/runnumber-rest/database.py +++ b/runnumber-rest/database.py @@ -11,6 +11,6 @@ class RunNumber(db.Model): 'flag', db.Boolean, nullable=False, default=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=db.func.now() + 'start_time', db.DateTime(timezone=True), nullable=False, default=db.func.now() ) - stop_time = db.Column('stop_time', db.TIMESTAMP(6), nullable=True) + stop_time = db.Column('stop_time', db.DateTime(timezone=True), nullable=True) diff --git a/runregistry-rest/database.py b/runregistry-rest/database.py index 40ce26d..8f96653 100644 --- a/runregistry-rest/database.py +++ b/runregistry-rest/database.py @@ -8,10 +8,10 @@ class RunRegistryMeta(db.Model): 'run_number', db.Integer, primary_key=True, autoincrement=True, nullable=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(6), nullable=False, default=db.func.now() + 'start_time', db.DateTime(timezone=True), nullable=False, default=db.func.now() ) stop_time = db.Column( - 'stop_time', db.TIMESTAMP(6), nullable=True + 'stop_time', db.DateTime(timezone=True), nullable=True ) detector_id = db.Column( 'detector_id', db.String(40) From 8b862f15fede1a4ccac9efe3d8486dc31f0abfbf Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 16 Apr 2024 17:01:33 +0200 Subject: [PATCH 17/18] trying out more time fixes 2.0 --- runnumber-rest/database.py | 4 ++-- runregistry-rest/database.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runnumber-rest/database.py b/runnumber-rest/database.py index 23fb9ce..084fb48 100644 --- a/runnumber-rest/database.py +++ b/runnumber-rest/database.py @@ -11,6 +11,6 @@ class RunNumber(db.Model): 'flag', db.Boolean, nullable=False, default=False ) start_time = db.Column( - 'start_time', db.DateTime(timezone=True), nullable=False, default=db.func.now() + 'start_time', db.TIMESTAMP(timezone=True), nullable=False, default=db.func.now() ) - stop_time = db.Column('stop_time', db.DateTime(timezone=True), nullable=True) + stop_time = db.Column('stop_time', db.TIMESTAMP(timezone=True), nullable=True) diff --git a/runregistry-rest/database.py b/runregistry-rest/database.py index 8f96653..5fc2349 100644 --- a/runregistry-rest/database.py +++ b/runregistry-rest/database.py @@ -8,10 +8,10 @@ class RunRegistryMeta(db.Model): 'run_number', db.Integer, primary_key=True, autoincrement=True, nullable=False ) start_time = db.Column( - 'start_time', db.DateTime(timezone=True), nullable=False, default=db.func.now() + 'start_time', db.TIMESTAMP(timezone=True), nullable=False, default=db.func.now() ) stop_time = db.Column( - 'stop_time', db.DateTime(timezone=True), nullable=True + 'stop_time', db.TIMESTAMP(timezone=True), nullable=True ) detector_id = db.Column( 'detector_id', db.String(40) From a87765f8745e4f551d731f9ad3f54db48cc1ffe3 Mon Sep 17 00:00:00 2001 From: titavare Date: Tue, 16 Apr 2024 17:10:51 +0200 Subject: [PATCH 18/18] trying out more time fixes 3.0 --- runregistry-rest/database.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runregistry-rest/database.py b/runregistry-rest/database.py index 5fc2349..3b0d20a 100644 --- a/runregistry-rest/database.py +++ b/runregistry-rest/database.py @@ -8,10 +8,10 @@ class RunRegistryMeta(db.Model): 'run_number', db.Integer, primary_key=True, autoincrement=True, nullable=False ) start_time = db.Column( - 'start_time', db.TIMESTAMP(timezone=True), nullable=False, default=db.func.now() + 'start_time', db.TIMESTAMP(local_timezone=True), nullable=False, default=db.func.now() ) stop_time = db.Column( - 'stop_time', db.TIMESTAMP(timezone=True), nullable=True + 'stop_time', db.TIMESTAMP(local_timezone=True), nullable=True ) detector_id = db.Column( 'detector_id', db.String(40)