Skip to content

Commit 7845eca

Browse files
committed
feat: more precise log
1 parent e754104 commit 7845eca

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

services/staging/rs_server_staging/main.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
init_rs_server_config_yaml,
3232
)
3333
from rs_server_common.db import Base
34-
from rs_server_common.settings import env_bool
34+
from rs_server_common.settings import LOCAL_MODE
3535
from rs_server_common.utils import opentelemetry
3636
from rs_server_common.utils.logging import Logging
3737
from rs_server_common.utils.utils2 import filelock
@@ -52,8 +52,6 @@
5252
from . import jobs_table # DON'T REMOVE (needed for SQLAlchemy)
5353
from .rspy_models import ProcessMetadataModel
5454

55-
LOCAL_MODE = env_bool("RSPY_LOCAL_MODE", default=False)
56-
5755
logger = Logging.default(__name__)
5856

5957
# Initialize a FastAPI application

services/staging/rs_server_staging/processors.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"""RSPY Staging processor."""
1515

1616
import asyncio # for handling asynchronous tasks
17+
import json
1718
import os
1819
import time
1920
import uuid
@@ -37,15 +38,13 @@
3738
load_external_auth_config_by_domain,
3839
)
3940
from rs_server_common.s3_storage_handler.s3_storage_handler import S3StorageHandler
40-
from rs_server_common.settings import env_bool
41+
from rs_server_common.settings import LOCAL_MODE
4142
from rs_server_common.utils.logging import Logging
4243
from starlette.datastructures import Headers
4344
from starlette.requests import Request
4445

4546
from .rspy_models import Feature, FeatureCollectionModel
4647

47-
LOCAL_MODE = env_bool("RSPY_LOCAL_MODE", default=False)
48-
4948

5049
# Custom authentication class
5150
class TokenAuth(AuthBase):
@@ -703,8 +702,10 @@ def dask_cluster_connect(self) -> Client: # pylint: disable=too-many-branches,t
703702
address=os.environ["DASK_GATEWAY__ADDRESS"],
704703
auth=gateway_auth,
705704
)
706-
clusters = gateway.list_clusters()
707-
self.logger.debug(f"The list of clusters: {clusters}")
705+
706+
# Sort the clusters by newest first
707+
clusters = sorted(gateway.list_clusters(), key=lambda cluster: cluster.start_time, reverse=True)
708+
self.logger.debug(f"Cluster list for gateway {os.environ['DASK_GATEWAY__ADDRESS']!r}:{clusters}")
708709

709710
# In local mode, get the first cluster from the gateway.
710711
cluster_id = None
@@ -725,11 +726,11 @@ def dask_cluster_connect(self) -> Client: # pylint: disable=too-many-branches,t
725726
)
726727

727728
if not cluster_id:
728-
raise IndexError(f"No dask cluster named '{cluster_name}' was found.")
729+
raise IndexError(f"Dask cluster with 'cluster_name'={cluster_name!r} was not found.")
729730

730731
self.cluster = gateway.connect(cluster_id)
731-
732732
self.logger.info(f"Successfully connected to the {cluster_name} dask cluster")
733+
733734
except KeyError as e:
734735
self.logger.exception(
735736
"Failed to retrieve the required connection details for "

0 commit comments

Comments
 (0)