Skip to content

Commit 6fe369f

Browse files
committed
removed debug statements
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent deef881 commit 6fe369f

File tree

4 files changed

+15
-82
lines changed

4 files changed

+15
-82
lines changed

.github/workflows/code-quality-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
# run test suite
6262
#----------------------------------------------
6363
- name: Run tests
64-
run: poetry run python -m pytest tests/unit -v -s
64+
run: poetry run python -m pytest tests/unit
6565
run-unit-tests-with-arrow:
6666
runs-on: ubuntu-latest
6767
strategy:
@@ -112,7 +112,7 @@ jobs:
112112
# run test suite
113113
#----------------------------------------------
114114
- name: Run tests
115-
run: poetry run python -m pytest tests/unit -v -s
115+
run: poetry run python -m pytest tests/unit
116116
check-linting:
117117
runs-on: ubuntu-latest
118118
strategy:

src/databricks/sql/client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def read(self) -> Optional[OAuthToken]:
305305
self.use_inline_params = self._set_use_inline_params_with_warning(
306306
kwargs.get("use_inline_params", False)
307307
)
308-
print("Connection init : session_id_hex", self.get_session_id_hex(), flush=True)
308+
309309
TelemetryClientFactory.initialize_telemetry_client(
310310
telemetry_enabled=self.telemetry_enabled,
311311
session_id_hex=self.get_session_id_hex(),
@@ -377,11 +377,6 @@ def __del__(self):
377377
"Closing unclosed connection for session "
378378
"{}".format(self.get_session_id_hex())
379379
)
380-
print(
381-
"LMAO GC closing connection IN MAIN THREAD (INTERRUPTS EVERYTHING): ",
382-
self.get_session_id_hex(),
383-
flush=True,
384-
)
385380
try:
386381
self._close(close_cursors=False)
387382
except OperationalError as e:
@@ -445,9 +440,6 @@ def cursor(
445440

446441
def close(self) -> None:
447442
"""Close the underlying session and mark all associated cursors as closed."""
448-
print(
449-
"Connection close: session_id_hex: ", self.get_session_id_hex(), flush=True
450-
)
451443
self._close()
452444

453445
def _close(self, close_cursors=True) -> None:

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -367,27 +367,12 @@ def initialize_telemetry_client(
367367
"""Initialize a telemetry client for a specific connection if telemetry is enabled"""
368368
try:
369369

370-
print(
371-
"\nWAITING: Initializing telemetry client: %s",
372-
session_id_hex,
373-
flush=True,
374-
)
375370
with TelemetryClientFactory._lock:
376-
print(
377-
"\nACQUIRED: Initializing telemetry client, got lock: %s",
378-
session_id_hex,
379-
flush=True,
380-
)
381-
TelemetryClientFactory._initialize()
382-
print(
383-
"\n TelemetryClientFactory initialized: %s",
384-
session_id_hex,
385-
flush=True,
386-
)
387371

372+
TelemetryClientFactory._initialize()
388373
if session_id_hex not in TelemetryClientFactory._clients:
389-
print(
390-
"\n Session ID not in clients: %s",
374+
logger.debug(
375+
"Session ID not in clients: %s",
391376
session_id_hex,
392377
flush=True,
393378
)
@@ -396,7 +381,6 @@ def initialize_telemetry_client(
396381
session_id_hex,
397382
)
398383
if telemetry_enabled:
399-
print("\n Telemetry enabled: %s", session_id_hex, flush=True)
400384
TelemetryClientFactory._clients[
401385
session_id_hex
402386
] = TelemetryClient(
@@ -406,41 +390,16 @@ def initialize_telemetry_client(
406390
host_url=host_url,
407391
executor=TelemetryClientFactory._executor,
408392
)
409-
print(
410-
"\n Telemetry client initialized: %s",
411-
session_id_hex,
412-
flush=True,
413-
)
414393
else:
415-
print(
416-
"\n Telemetry disabled: %s", session_id_hex, flush=True
417-
)
394+
logger.debug("Telemetry disabled: %s", session_id_hex)
418395
TelemetryClientFactory._clients[
419396
session_id_hex
420397
] = NoopTelemetryClient()
421-
print(
422-
"\n Noop Telemetry client initialized: %s",
423-
session_id_hex,
424-
flush=True,
398+
logger.debug(
399+
"Noop Telemetry client initialized: %s", session_id_hex
425400
)
426-
else:
427-
print(
428-
"\n Session ID already in clients: %s",
429-
session_id_hex,
430-
flush=True,
431-
)
432-
print(
433-
"\nRELEASED: Telemetry client initialized: %s",
434-
session_id_hex,
435-
flush=True,
436-
)
401+
437402
except Exception as e:
438-
print(
439-
"\nERROR: Failed to initialize telemetry client: %s due to %s",
440-
session_id_hex,
441-
e,
442-
flush=True,
443-
)
444403
logger.debug("Failed to initialize telemetry client: %s", e)
445404
# Fallback to NoopTelemetryClient to ensure connection doesn't fail
446405
TelemetryClientFactory._clients[session_id_hex] = NoopTelemetryClient()
@@ -464,19 +423,12 @@ def get_telemetry_client(session_id_hex):
464423
@staticmethod
465424
def close(session_id_hex):
466425
"""Close and remove the telemetry client for a specific connection"""
467-
print("\nWAITING: Closing telemetry client: %s", session_id_hex, flush=True)
468426
with TelemetryClientFactory._lock:
469-
print(
470-
"\nACQUIRED: Closing telemetry client, got lock: %s",
471-
session_id_hex,
472-
flush=True,
473-
)
474-
# if (
475-
# telemetry_client := TelemetryClientFactory._clients.pop(
476-
# session_id_hex, None
477-
# )
478-
# ) is not None:
479-
if session_id_hex in TelemetryClientFactory._clients:
427+
if (
428+
telemetry_client := TelemetryClientFactory._clients.pop(
429+
session_id_hex, None
430+
)
431+
) is not None:
480432
logger.debug(
481433
"Removing telemetry client for connection %s", session_id_hex
482434
)
@@ -488,16 +440,6 @@ def close(session_id_hex):
488440
logger.debug(
489441
"No more telemetry clients, shutting down thread pool executor"
490442
)
491-
print(
492-
"\nSHUTDOWN: Shutting down thread pool executor: %s",
493-
session_id_hex,
494-
flush=True,
495-
)
496443
TelemetryClientFactory._executor.shutdown(wait=True)
497444
TelemetryClientFactory._executor = None
498445
TelemetryClientFactory._initialized = False
499-
print(
500-
"\nRELEASED: Thread pool executor shut down: %s",
501-
session_id_hex,
502-
flush=True,
503-
)

tests/unit/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ def test_context_manager_closes_cursor(self):
353353

354354
@patch("%s.client.ThriftBackend" % PACKAGE_NAME)
355355
def test_context_manager_closes_connection(self, mock_client_class):
356-
print("stalling test")
357356
instance = mock_client_class.return_value
358357

359358
mock_open_session_resp = MagicMock(spec=TOpenSessionResp)()

0 commit comments

Comments
 (0)