mirror of
https://gitea.psi.ch/APOG/acsmnode.git
synced 2025-06-28 20:30:48 +02:00
Fix bug reported in TODO.md. FLAGGING APP didnt record the parent channel correctly, that is the channel that originated a particular flag. An additional problem was detected and corrected where _metadata.json was confused as flag.
This commit is contained in:
@ -72,7 +72,7 @@ EnableVisCheckbox = dbc.Col(dbc.Row([dbc.Col(dcc.Checklist(
|
|||||||
width=12)
|
width=12)
|
||||||
|
|
||||||
FlagVisTable = html.Div(dash_table.DataTable(data=[],
|
FlagVisTable = html.Div(dash_table.DataTable(data=[],
|
||||||
columns=[{"name": i, "id": i} for i in ['id','startdate','enddate','description','parent_ch_pos','parent_channel']],
|
columns=[{"name": i, "id": i} for i in ['id','startdate','enddate','description','parent_channel']],
|
||||||
id='tbl',
|
id='tbl',
|
||||||
style_header={'textAlign': 'center'},
|
style_header={'textAlign': 'center'},
|
||||||
fixed_rows={'headers': True}, # Fixed table headers
|
fixed_rows={'headers': True}, # Fixed table headers
|
||||||
@ -237,10 +237,10 @@ def load_data(filename, contents):
|
|||||||
return data, instrument_list, False
|
return data, instrument_list, False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
DataOps.unload_file_obj()
|
|
||||||
print(f"Error processing file: {e}")
|
print(f"Error processing file: {e}")
|
||||||
return data, [], False
|
return data, [], False
|
||||||
|
finally:
|
||||||
|
DataOps.unload_file_obj()
|
||||||
|
|
||||||
|
|
||||||
return data, [], False
|
return data, [], False
|
||||||
@ -363,6 +363,7 @@ def update_figure(instFolderName, fileName, variableList, data):
|
|||||||
if not path_to_file:
|
if not path_to_file:
|
||||||
return go.Figure(), dash.no_update
|
return go.Figure(), dash.no_update
|
||||||
|
|
||||||
|
try:
|
||||||
DataOps = hdf5_ops.HDF5DataOpsManager(path_to_file)
|
DataOps = hdf5_ops.HDF5DataOpsManager(path_to_file)
|
||||||
DataOps.load_file_obj()
|
DataOps.load_file_obj()
|
||||||
dataset_name = '/'.join([instFolderName, fileName, 'data_table'])
|
dataset_name = '/'.join([instFolderName, fileName, 'data_table'])
|
||||||
@ -375,6 +376,10 @@ def update_figure(instFolderName, fileName, variableList, data):
|
|||||||
path_to_file, instFolderName, dataset_name, datetime_var, datetime_var_format, variableList
|
path_to_file, instFolderName, dataset_name, datetime_var, datetime_var_format, variableList
|
||||||
)
|
)
|
||||||
data['channel_names'] = channel_names
|
data['channel_names'] = channel_names
|
||||||
|
except Exception as e:
|
||||||
|
print(f'While processing file {path_to_file}, we got the following exception {e}.')
|
||||||
|
finally:
|
||||||
|
DataOps.unload_file_obj()
|
||||||
return fig, data
|
return fig, data
|
||||||
|
|
||||||
|
|
||||||
@ -541,7 +546,7 @@ def clear_flag_mode_title(relayoutData, fig, data):
|
|||||||
return dash.no_update, dash.no_update, dash.no_update
|
return dash.no_update, dash.no_update, dash.no_update
|
||||||
|
|
||||||
def extract_number(s):
|
def extract_number(s):
|
||||||
return int(s[1:]) if s[1:].isdigit() else 0
|
return int(s[1:])-1 if s[1:].isdigit() else 0
|
||||||
|
|
||||||
@callback(Output('tbl', 'data'),
|
@callback(Output('tbl', 'data'),
|
||||||
Input('commit-flag-button','n_clicks'),
|
Input('commit-flag-button','n_clicks'),
|
||||||
@ -585,10 +590,11 @@ def commit_flag(n_clicks,flag_value,selected_Data, data):
|
|||||||
#dirlist = dirlist.sort(key=lambda x: int(x.split('_')[1].split('.')[0]))
|
#dirlist = dirlist.sort(key=lambda x: int(x.split('_')[1].split('.')[0]))
|
||||||
|
|
||||||
display_flag_registry = True
|
display_flag_registry = True
|
||||||
if not display_flag_registry:
|
if display_flag_registry:
|
||||||
tableData = []
|
|
||||||
else:
|
|
||||||
tableData = data_flagging_utils.load_flags(flagfolderpath)
|
tableData = data_flagging_utils.load_flags(flagfolderpath)
|
||||||
|
else:
|
||||||
|
tableData = []
|
||||||
|
|
||||||
|
|
||||||
#tableData = []
|
#tableData = []
|
||||||
#for pathtofile in dirlist_sorted_by_creation:
|
#for pathtofile in dirlist_sorted_by_creation:
|
||||||
@ -763,13 +769,16 @@ def visualize_flags_on_table(n_clicks,value,memoryData):
|
|||||||
|
|
||||||
|
|
||||||
def open_browser():
|
def open_browser():
|
||||||
"""Wait for the server to start, then open the browser."""
|
"""Wait for the server to start, then open the browser (only on the host)."""
|
||||||
sleep(1) # Wait briefly to ensure the server is starting
|
sleep(1) # Give the server time to start
|
||||||
|
|
||||||
|
# Open in browser only if running outside Docker
|
||||||
|
if not os.getenv("DOCKER_CONTAINER"):
|
||||||
webbrowser.open_new("http://127.0.0.1:8050/")
|
webbrowser.open_new("http://127.0.0.1:8050/")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Start the browser-opening function in a separate thread
|
# Start the browser-opening function in a separate thread
|
||||||
threading.Thread(target=open_browser).start()
|
threading.Thread(target=open_browser).start()
|
||||||
|
|
||||||
# Run the Dash app server
|
# Run the Dash app server on 0.0.0.0 to allow external access
|
||||||
app.run_server(debug=True, use_reloader=False)
|
app.run_server(host="0.0.0.0", port=8050, debug=True, use_reloader=False)
|
@ -70,7 +70,7 @@ def create_loaded_file_figure(file_path, instFolder, dataset_name, datetime_var,
|
|||||||
datetime_var_format)
|
datetime_var_format)
|
||||||
|
|
||||||
#time_column = dataset[datetime_var][:]
|
#time_column = dataset[datetime_var][:]
|
||||||
for i in range(1,len(variables)):
|
for i in range(0,len(variables)):
|
||||||
|
|
||||||
fig.add_trace(go.Scatter(x = time_column,
|
fig.add_trace(go.Scatter(x = time_column,
|
||||||
y = dataset[variables[i]][:],
|
y = dataset[variables[i]][:],
|
||||||
@ -140,7 +140,7 @@ def load_flags(flagFolderPath, dry_run : bool = False): #filePath, instFolder, d
|
|||||||
# Process and load JSON files
|
# Process and load JSON files
|
||||||
flagDataList = []
|
flagDataList = []
|
||||||
for filePath in sortedFiles:
|
for filePath in sortedFiles:
|
||||||
if filePath.endswith('.json'):
|
if filePath.endswith('.json') and not filePath.endswith('metadata.json'):
|
||||||
try:
|
try:
|
||||||
with open(filePath, 'r') as file:
|
with open(filePath, 'r') as file:
|
||||||
flagDataList.append(json.load(file))
|
flagDataList.append(json.load(file))
|
||||||
|
Reference in New Issue
Block a user