bfabric-web-apps 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bfabric_web_apps/__init__.py +4 -1
- bfabric_web_apps/layouts/layouts.py +58 -52
- bfabric_web_apps/objects/Logger.py +1 -1
- bfabric_web_apps/utils/callbacks.py +5 -5
- bfabric_web_apps/utils/config.py +4 -0
- bfabric_web_apps/utils/redis_connection.py +9 -1
- bfabric_web_apps/utils/redis_worker_init.py +36 -6
- {bfabric_web_apps-0.2.1.dist-info → bfabric_web_apps-0.2.3.dist-info}/METADATA +1 -1
- {bfabric_web_apps-0.2.1.dist-info → bfabric_web_apps-0.2.3.dist-info}/RECORD +11 -11
- {bfabric_web_apps-0.2.1.dist-info → bfabric_web_apps-0.2.3.dist-info}/LICENSE +0 -0
- {bfabric_web_apps-0.2.1.dist-info → bfabric_web_apps-0.2.3.dist-info}/WHEEL +0 -0
bfabric_web_apps/__init__.py
CHANGED
@@ -63,4 +63,7 @@ TRX_SSH_KEY = config.TRX_SSH_KEY
|
|
63
63
|
URL = config.URL
|
64
64
|
|
65
65
|
SERVICE_ID = config.SERVICE_ID
|
66
|
-
DATASET_TEMPLATE_ID = config.DATASET_TEMPLATE_ID
|
66
|
+
DATASET_TEMPLATE_ID = config.DATASET_TEMPLATE_ID
|
67
|
+
|
68
|
+
REDIS_USERNAME = config.REDIS_USERNAME
|
69
|
+
REDIS_PASSWORD = config.REDIS_PASSWORD
|
@@ -2,7 +2,7 @@ from dash import html, dcc
|
|
2
2
|
import dash_bootstrap_components as dbc
|
3
3
|
import bfabric_web_apps
|
4
4
|
|
5
|
-
def get_static_layout(base_title=None, main_content=None, documentation_content=None, layout_config={}):
|
5
|
+
def get_static_layout(base_title=None, main_content=None, documentation_content=None, layout_config={}, include_header=True):
|
6
6
|
"""
|
7
7
|
Returns a layout with static tabs for Main, Documentation, and Report a Bug.
|
8
8
|
The main content is customizable, while the other tabs are generic.
|
@@ -29,6 +29,62 @@ def get_static_layout(base_title=None, main_content=None, documentation_content=
|
|
29
29
|
if layout_config.get("bug", False):
|
30
30
|
tab_list.append(dbc.Tab(dcc.Loading(get_report_bug_tab()), label="Report a Bug", tab_id="report-bug"))
|
31
31
|
|
32
|
+
if not include_header:
|
33
|
+
header_row = dbc.Row()
|
34
|
+
|
35
|
+
else:
|
36
|
+
header_row = dbc.Row(
|
37
|
+
dbc.Col(
|
38
|
+
html.Div(
|
39
|
+
children=[
|
40
|
+
# Page Title (Aligned Left)
|
41
|
+
html.P(
|
42
|
+
id="page-title",
|
43
|
+
children=[str(" ")],
|
44
|
+
style={"font-size": "40px", "margin-left": "20px", "margin-top": "10px"}
|
45
|
+
),
|
46
|
+
|
47
|
+
# View Logs Button (Aligned Right)
|
48
|
+
html.Div(
|
49
|
+
children=[
|
50
|
+
html.A(
|
51
|
+
dbc.Button(
|
52
|
+
"View Logs",
|
53
|
+
id="dynamic-link-button",
|
54
|
+
color="secondary", # Greyish color
|
55
|
+
style={
|
56
|
+
"font-size": "18px",
|
57
|
+
"padding": "10px 20px",
|
58
|
+
"border-radius": "8px"
|
59
|
+
}
|
60
|
+
),
|
61
|
+
id="dynamic-link",
|
62
|
+
href="#", # Will be dynamically set in the callback
|
63
|
+
target="_blank"
|
64
|
+
)
|
65
|
+
],
|
66
|
+
style={
|
67
|
+
"position": "absolute",
|
68
|
+
"right": "20px",
|
69
|
+
"top": "10px", # Aligns with title
|
70
|
+
}
|
71
|
+
),
|
72
|
+
],
|
73
|
+
style={
|
74
|
+
"position": "relative", # Ensures absolute positioning works
|
75
|
+
"margin-top": "0px",
|
76
|
+
"min-height": "80px",
|
77
|
+
"height": "6vh",
|
78
|
+
"border-bottom": "2px solid #d4d7d9",
|
79
|
+
"display": "flex",
|
80
|
+
"align-items": "center",
|
81
|
+
"justify-content": "space-between", # Title left, button right
|
82
|
+
"padding-right": "20px" # Space between button & right edge
|
83
|
+
}
|
84
|
+
),
|
85
|
+
),
|
86
|
+
)
|
87
|
+
|
32
88
|
return html.Div(
|
33
89
|
children=[
|
34
90
|
dcc.Location(id='url', refresh=False),
|
@@ -70,57 +126,7 @@ def get_static_layout(base_title=None, main_content=None, documentation_content=
|
|
70
126
|
),
|
71
127
|
|
72
128
|
# Page Title Section + View Logs Button (Aligned Right)
|
73
|
-
|
74
|
-
dbc.Col(
|
75
|
-
html.Div(
|
76
|
-
children=[
|
77
|
-
# Page Title (Aligned Left)
|
78
|
-
html.P(
|
79
|
-
id="page-title",
|
80
|
-
children=[str(" ")],
|
81
|
-
style={"font-size": "40px", "margin-left": "20px", "margin-top": "10px"}
|
82
|
-
),
|
83
|
-
|
84
|
-
# View Logs Button (Aligned Right)
|
85
|
-
html.Div(
|
86
|
-
children=[
|
87
|
-
html.A(
|
88
|
-
dbc.Button(
|
89
|
-
"View Logs",
|
90
|
-
id="dynamic-link-button",
|
91
|
-
color="secondary", # Greyish color
|
92
|
-
style={
|
93
|
-
"font-size": "18px",
|
94
|
-
"padding": "10px 20px",
|
95
|
-
"border-radius": "8px"
|
96
|
-
}
|
97
|
-
),
|
98
|
-
id="dynamic-link",
|
99
|
-
href="#", # Will be dynamically set in the callback
|
100
|
-
target="_blank"
|
101
|
-
)
|
102
|
-
],
|
103
|
-
style={
|
104
|
-
"position": "absolute",
|
105
|
-
"right": "20px",
|
106
|
-
"top": "10px", # Aligns with title
|
107
|
-
}
|
108
|
-
),
|
109
|
-
],
|
110
|
-
style={
|
111
|
-
"position": "relative", # Ensures absolute positioning works
|
112
|
-
"margin-top": "0px",
|
113
|
-
"min-height": "80px",
|
114
|
-
"height": "6vh",
|
115
|
-
"border-bottom": "2px solid #d4d7d9",
|
116
|
-
"display": "flex",
|
117
|
-
"align-items": "center",
|
118
|
-
"justify-content": "space-between", # Title left, button right
|
119
|
-
"padding-right": "20px" # Space between button & right edge
|
120
|
-
}
|
121
|
-
),
|
122
|
-
),
|
123
|
-
),
|
129
|
+
header_row,
|
124
130
|
|
125
131
|
# Bug Report Alerts (Restored)
|
126
132
|
dbc.Row(
|
@@ -18,7 +18,7 @@ class Logger:
|
|
18
18
|
Args:
|
19
19
|
jobid (int): The ID of the current job.
|
20
20
|
username (str): The name of the user performing the operations.
|
21
|
-
environment (str): The environment (e.g.,
|
21
|
+
environment (str): The environment (e.g., production, test).
|
22
22
|
"""
|
23
23
|
self.jobid = jobid
|
24
24
|
self.username = username
|
@@ -53,6 +53,8 @@ def process_url_and_token(url_params):
|
|
53
53
|
) if tdata else "Bfabric App Interface"
|
54
54
|
|
55
55
|
environment = tdata.get("environment", "").strip().lower() # 'test' or 'prod'
|
56
|
+
tdata["environment"] = environment.lower()
|
57
|
+
|
56
58
|
job_id = tdata.get("jobId", None) # Extract job ID
|
57
59
|
|
58
60
|
job_link = None
|
@@ -114,8 +116,6 @@ def submit_bug_report(n_clicks, bug_description, token, entity_data):
|
|
114
116
|
else:
|
115
117
|
token_data = {}
|
116
118
|
|
117
|
-
print(token_data)
|
118
|
-
|
119
119
|
# Extract logging-related information from token_data, with defaults for missing values
|
120
120
|
jobId = token_data.get('jobId', None)
|
121
121
|
username = token_data.get("user_data", "None")
|
@@ -184,8 +184,8 @@ def populate_workunit_details(token_data):
|
|
184
184
|
"""
|
185
185
|
|
186
186
|
environment_urls = {
|
187
|
-
"
|
188
|
-
"
|
187
|
+
"test": "https://fgcz-bfabric-test.uzh.ch/bfabric/workunit/show.html?id=",
|
188
|
+
"production": "https://fgcz-bfabric.uzh.ch/bfabric/workunit/show.html?id="
|
189
189
|
}
|
190
190
|
|
191
191
|
if token_data:
|
@@ -223,7 +223,7 @@ def populate_workunit_details(token_data):
|
|
223
223
|
html.P(f"Status: {wu.get('status', 'n/a')}")
|
224
224
|
])
|
225
225
|
], style={"width": "400px", "margin":"10px"}),
|
226
|
-
href=environment_urls[token_data.get("environment", "
|
226
|
+
href=environment_urls[token_data.get("environment", "test")] + str(wu["id"]),
|
227
227
|
target="_blank",
|
228
228
|
style={"text-decoration": "none"}
|
229
229
|
)
|
bfabric_web_apps/utils/config.py
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
from pydantic_settings import BaseSettings
|
2
2
|
from pydantic import EmailStr
|
3
|
+
from typing import Optional
|
3
4
|
|
4
5
|
class Settings(BaseSettings):
|
5
6
|
|
6
7
|
REDIS_HOST: str = "localhost"
|
7
8
|
REDIS_PORT: int = 6379
|
9
|
+
|
10
|
+
REDIS_USERNAME: Optional[str] = None
|
11
|
+
REDIS_PASSWORD: Optional[str] = None
|
8
12
|
|
9
13
|
CONFIG_FILE_PATH: str = "~/.bfabricpy.yml"
|
10
14
|
|
@@ -3,4 +3,12 @@ from .config import settings as config
|
|
3
3
|
|
4
4
|
from redis import Redis
|
5
5
|
|
6
|
-
|
6
|
+
if config.REDIS_USERNAME and config.REDIS_PASSWORD:
|
7
|
+
redis_conn = Redis(
|
8
|
+
host=config.REDIS_HOST,
|
9
|
+
port=config.REDIS_PORT,
|
10
|
+
username=config.REDIS_USERNAME,
|
11
|
+
password=config.REDIS_PASSWORD
|
12
|
+
)
|
13
|
+
else:
|
14
|
+
redis_conn = Redis(host=config.REDIS_HOST, port=config.REDIS_PORT)
|
@@ -20,15 +20,45 @@ def keepalive_ping(conn, interval=60):
|
|
20
20
|
print("Redis keepalive ping failed:", e)
|
21
21
|
time.sleep(interval)
|
22
22
|
|
23
|
-
def run_worker(host, port, queue_names):
|
23
|
+
def run_worker(host, port, queue_names, username=None, password=None):
|
24
24
|
"""
|
25
25
|
Starts an RQ worker with a background Redis keepalive thread to prevent Azure from dropping idle connections.
|
26
26
|
"""
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
|
28
|
+
def build_redis(protocol=2):
|
29
|
+
|
30
|
+
if username and password:
|
31
|
+
|
32
|
+
print("Connecting to Redis with authentication.")
|
33
|
+
print(f"Host: {host}, Port: {port}, Username: {username}")
|
34
|
+
|
35
|
+
conn = redis.Redis(
|
36
|
+
host=host,
|
37
|
+
port=port,
|
38
|
+
username=username,
|
39
|
+
password=password,
|
40
|
+
socket_keepalive=True,
|
41
|
+
protocol=protocol
|
42
|
+
)
|
43
|
+
|
44
|
+
else:
|
45
|
+
|
46
|
+
print("Connecting to Redis without authentication.")
|
47
|
+
print(f"Host: {host}, Port: {port}")
|
48
|
+
|
49
|
+
conn = redis.Redis(
|
50
|
+
host=host,
|
51
|
+
port=port,
|
52
|
+
socket_keepalive=True,
|
53
|
+
protocol=protocol
|
54
|
+
)
|
55
|
+
return conn
|
56
|
+
|
57
|
+
try:
|
58
|
+
conn = build_redis(protocol=2)
|
59
|
+
except Exception as e:
|
60
|
+
print("Failed to connect to Redis with protocol 2, trying protocol 3...")
|
61
|
+
conn = build_redis(protocol=3)
|
32
62
|
|
33
63
|
# Start Redis keepalive thread
|
34
64
|
threading.Thread(target=keepalive_ping, args=(conn,), daemon=True).start()
|
@@ -1,22 +1,22 @@
|
|
1
|
-
bfabric_web_apps/__init__.py,sha256=
|
2
|
-
bfabric_web_apps/layouts/layouts.py,sha256=
|
1
|
+
bfabric_web_apps/__init__.py,sha256=4ldtAK1Qs9l5xb8t2M3VL4oRmpQB5Qi71z2VZtfJGRI,1794
|
2
|
+
bfabric_web_apps/layouts/layouts.py,sha256=aqFG2wswbtm1Tq5xQgDI9d8CK6H46aQpru4QhDWRbdc,14197
|
3
3
|
bfabric_web_apps/objects/BfabricInterface.py,sha256=iz3m3SXtUVaEMm0ZRm-2IFePd2UkVu1ob87mq1ogLXA,10751
|
4
|
-
bfabric_web_apps/objects/Logger.py,sha256=
|
4
|
+
bfabric_web_apps/objects/Logger.py,sha256=TdioFzxTHuXTRD1X2N9Pm2OlqcoPTzzXy_WQyt7lSNA,5224
|
5
5
|
bfabric_web_apps/utils/app_init.py,sha256=RCdpCXp19cF74bouYJLPe-KSETZ0Vwqtd02Ta2VXEF8,428
|
6
|
-
bfabric_web_apps/utils/callbacks.py,sha256=
|
6
|
+
bfabric_web_apps/utils/callbacks.py,sha256=6ji5qsJpJa6MUnrwF_ypGRkSxjOv24-X-o9HREyjGQA,12716
|
7
7
|
bfabric_web_apps/utils/charging.py,sha256=oNNazH59SFkbxJKPvCel0IxdsRHC8xpJ0AXCLvI88FI,1069
|
8
8
|
bfabric_web_apps/utils/components.py,sha256=X3NRnv--LsHWMtWL83Pzr2whOZLSEJIwXTklQdAQpZE,984
|
9
|
-
bfabric_web_apps/utils/config.py,sha256=
|
9
|
+
bfabric_web_apps/utils/config.py,sha256=gqTsO5tFWL7JVTzZgSk5xiyCrhJsBz3veoPBqHWAKC4,1324
|
10
10
|
bfabric_web_apps/utils/create_app_in_bfabric.py,sha256=Z7puke8QB4SBuDJ9x3_OjgApzovKu0Nt1g8EqkOHJpc,2758
|
11
11
|
bfabric_web_apps/utils/dataset_utils.py,sha256=p_UtoOl1kJpSm2BGdg31Ji0C7ctst40wp4LX1tUe4tI,3360
|
12
12
|
bfabric_web_apps/utils/get_logger.py,sha256=0Y3SrXW93--eglS0_ZOc34NOriAt6buFPik5n0ltzRA,434
|
13
13
|
bfabric_web_apps/utils/get_power_user_wrapper.py,sha256=T33z64XjmJ0KSlmfEmrEP8eYpbpINCVD6Xld_V7PR2g,1027
|
14
|
-
bfabric_web_apps/utils/redis_connection.py,sha256=
|
14
|
+
bfabric_web_apps/utils/redis_connection.py,sha256=TPROVkI_gqlbiOorADfhpt26gby4xe7ppmxe8paVh8A,368
|
15
15
|
bfabric_web_apps/utils/redis_queue.py,sha256=MCx7z_I2NusJ4P42mcLvV7STtXBFMIIvun83fM8zOGI,168
|
16
|
-
bfabric_web_apps/utils/redis_worker_init.py,sha256=
|
16
|
+
bfabric_web_apps/utils/redis_worker_init.py,sha256=W_7XbvbGK7yDi2v7wO0WQJls0XYCsjs9ucn6-DLkPWc,1939
|
17
17
|
bfabric_web_apps/utils/resource_utilities.py,sha256=N4EiUkxXHZ18jnU2OuRqaGSroCZ73Ogb9lkeA21Kvq4,5716
|
18
18
|
bfabric_web_apps/utils/run_main_pipeline.py,sha256=-5o2QZW27OIvPJ_BtJ3s5UXoONOUcgUeXH4RSTN8oZg,23219
|
19
|
-
bfabric_web_apps-0.2.
|
20
|
-
bfabric_web_apps-0.2.
|
21
|
-
bfabric_web_apps-0.2.
|
22
|
-
bfabric_web_apps-0.2.
|
19
|
+
bfabric_web_apps-0.2.3.dist-info/LICENSE,sha256=k0O_i2k13i9e35aO-j7FerJafAqzzu8x0kkBs0OWF3c,1065
|
20
|
+
bfabric_web_apps-0.2.3.dist-info/METADATA,sha256=uXh6go9hrsjFLRCDmJwFsO4asuW_njZbLpW_KzgKKrY,687
|
21
|
+
bfabric_web_apps-0.2.3.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
22
|
+
bfabric_web_apps-0.2.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|