bfabric-web-apps 0.2.1__py3-none-any.whl → 0.2.2__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.
@@ -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
@@ -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., Production, Test).
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
- "Test": "https://fgcz-bfabric-test.uzh.ch/bfabric/workunit/show.html?id=",
188
- "Production": "https://fgcz-bfabric.uzh.ch/bfabric/workunit/show.html?id="
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", "Test")] + str(wu["id"]),
226
+ href=environment_urls[token_data.get("environment", "test")] + str(wu["id"]),
227
227
  target="_blank",
228
228
  style={"text-decoration": "none"}
229
229
  )
@@ -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
- redis_conn = Redis(host=config.REDIS_HOST, port=config.REDIS_PORT)
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
- conn = redis.Redis(
28
- host=host,
29
- port=port,
30
- socket_keepalive=True
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bfabric-web-apps
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A package containing handy boilerplate utilities for developing bfabric web-applications
5
5
  Author: Marc Zuber, Griffin White, GWC GmbH
6
6
  Requires-Python: >=3.10,<4.0
@@ -1,22 +1,22 @@
1
- bfabric_web_apps/__init__.py,sha256=eRYBvXrDM8Bhdm7cbI80L1hjtbRFqUasJiBW52Hx3TI,1715
1
+ bfabric_web_apps/__init__.py,sha256=4ldtAK1Qs9l5xb8t2M3VL4oRmpQB5Qi71z2VZtfJGRI,1794
2
2
  bfabric_web_apps/layouts/layouts.py,sha256=z8gL4n4wwLdpLGomO9CftBLnGpc3r6OpmUc2-wBg8uo,14661
3
3
  bfabric_web_apps/objects/BfabricInterface.py,sha256=iz3m3SXtUVaEMm0ZRm-2IFePd2UkVu1ob87mq1ogLXA,10751
4
- bfabric_web_apps/objects/Logger.py,sha256=62LC94xhm7YG5LUw3yH46NqvJQsAX7wnc9D4zbY16rA,5224
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=tB1xtHl_ePY6KJWNz3erkrZw3HFhRneewGqZm9xIYtI,12687
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=F4EExu7EkY7upOnxk6BU6zTLt9eU6_iy2y8esIlxTSc,1209
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=qXSPxW6m55Ogv44BhmPCl9ACuvzmpfZNU73UJhHRXL4,133
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=wtjQL48PLNXD1s-5s3Oq5EC8BmcfKcd7IhUbTH_EYz8,1014
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.1.dist-info/LICENSE,sha256=k0O_i2k13i9e35aO-j7FerJafAqzzu8x0kkBs0OWF3c,1065
20
- bfabric_web_apps-0.2.1.dist-info/METADATA,sha256=abK_cUI5x_js8GFj0gAHqo7pw7G98YW-IygicddE78o,687
21
- bfabric_web_apps-0.2.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
22
- bfabric_web_apps-0.2.1.dist-info/RECORD,,
19
+ bfabric_web_apps-0.2.2.dist-info/LICENSE,sha256=k0O_i2k13i9e35aO-j7FerJafAqzzu8x0kkBs0OWF3c,1065
20
+ bfabric_web_apps-0.2.2.dist-info/METADATA,sha256=FpsbVNdputwhaI3gZLnMms1F0inGRMKdatzZh89uycQ,687
21
+ bfabric_web_apps-0.2.2.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
22
+ bfabric_web_apps-0.2.2.dist-info/RECORD,,