shipcall evaluation now also supports a shipcall_id argument, so only a single Shipcall is evaluated. Updating requirements.txt after installing the virtual environment for the first time on a Windows laptop. Updating the berth-stub according to the recent berth changes (owner id & authority id).

This commit is contained in:
max_metz 2023-10-13 12:23:27 +02:00
parent e739d80433
commit b87aa23e28
5 changed files with 28 additions and 10 deletions

View File

@ -2,7 +2,7 @@
# 20231013:
Adding the shipcall evaluation (traffic state). Provided a one-line function to connect, evaluate and update the shipcalls in a database
The sql database can now be properly updated by SQL calls (using mysql.connector and pydapper)
Preparing a pull request, where all necessary changes are provided.
Created a pull request, where all necessary changes are provided.
# TODO: there must be a call function in the application, which asks for an update of the evaluation state & message. Discussing with Daniel Schick.

View File

@ -14,9 +14,6 @@ dependencies:
- ipython>=8.14.0=pyh41d4057_0
- jupyterlab>=4.0.5=pyhd8ed1ab_0
- mamba>=1.4.9=py311h3072747_0
- conda-forge::matplotlib-base>=3.7.2=py311h54ef318_0
- conda-forge::matplotlib>=3.7.2=py311h38be061_0
- matplotlib-inline>=0.1.6=pyhd8ed1ab_0
- conda-forge::pytest>=7.4.0=pyhd8ed1ab_0
- conda-forge::pytest-cov>=4.1.0=pyhd8ed1ab_0
- python>=3.11.4=hab00c5b_0_cpython

View File

@ -60,7 +60,7 @@ def update_all_shipcalls_in_mysql_database(sql_connection, sql_handler:SQLHandle
update_shipcall_in_mysql_database(sql_connection, shipcall=shipcall, relevant_keys = ["evaluation", "evaluation_message"])
return
def run_validation_rules(mysql_connector_instance, debug=False)->pd.DataFrame:
def run_validation_rules(mysql_connector_instance, shipcall_id:int=None, debug=False)->pd.DataFrame:
"""
options:
mysql_connector_instance: an instance created by the mysql.connector.connect() call. It is advised to use Python's context manager to close the connection after finished.
@ -74,6 +74,10 @@ def run_validation_rules(mysql_connector_instance, debug=False)->pd.DataFrame:
vr = ValidationRules(sql_handler)
shipcall_df = sql_handler.df_dict.get("shipcall")
if shipcall_id is not None:
shipcall_df = shipcall_df.loc[[shipcall_id]]
# placeholder: filter shipcalls. For example, exclude historic entries.
shipcall_df = vr.evaluate_shipcalls(shipcall_df)
@ -84,12 +88,16 @@ def run_validation_rules(mysql_connector_instance, debug=False)->pd.DataFrame:
update_all_shipcalls_in_mysql_database(sql_connection=mysql_connector_instance, sql_handler=sql_handler, shipcall_df=shipcall_df)
return shipcall_df
def update_shipcall_evaluation_state(mysql_connection_data)->pd.DataFrame:
def update_shipcall_evaluation_state(mysql_connection_data:dict, shipcall_id:int=None)->pd.DataFrame:
"""
single line function to connect to a mysql database (using the {mysql_connection_data}), evaluate each shipcall (bei traffic state)
and finally, update those in the database.
options:
mysql_connection_data: connection data to the mysql database (e.g., port, host, password)
shipcall_id: int. ID of the shipcall to be updated. Defaults to 'None'. When providing 'None', all shipcalls are updated.
"""
with mysql.connector.connect(**mysql_connection_data) as mysql_connector_instance:
shipcall_df = run_validation_rules(mysql_connector_instance=mysql_connector_instance, debug=False)
shipcall_df = run_validation_rules(mysql_connector_instance=mysql_connector_instance, shipcall_id=shipcall_id, debug=False)
return shipcall_df

View File

@ -7,8 +7,10 @@ def get_berth_simple():
# Note: #TODO: name, participant_id & lock state are arbitrary
name = "Avangard Dalben"
participant_id = 1 # e.g., Avangard
participant_id = 1# e.g., Avangard
lock = False
owner_id = 1 # e.g., Avangard
authority_id = 1 # e.g., Avangard
created = datetime.datetime.now()
modified = created+datetime.timedelta(seconds=10)
@ -19,6 +21,8 @@ def get_berth_simple():
name,
participant_id,
lock,
owner_id,
authority_id,
created,
modified,
deleted,

View File

@ -3,15 +3,24 @@ Flask==1.1.2
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
marshmallow==3.9.1
marshmallow>=3.9.1
webargs==6.1.1
Werkzeug==1.0.1
pydapper[mysql-connector-python]
marshmallow-dataclass
bcrypt
jwt
pyjwt
flask-jwt-extended
numpy
pandas
tqdm
schedule
pytest
pytest-cov
coverage
../server/.
../lib_brecal_utils/.