Skip to content

Commit e1a00be

Browse files
committed
formatting
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent 20884d3 commit e1a00be

File tree

3 files changed

+62
-25
lines changed

3 files changed

+62
-25
lines changed

src/databricks/sql/client.py

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
TSparkParameter,
5050
TOperationState,
5151
)
52-
from databricks.sql.telemetry.telemetry_client import telemetry_client, NoopTelemetryClient
52+
from databricks.sql.telemetry.telemetry_client import (
53+
telemetry_client,
54+
NoopTelemetryClient,
55+
)
5356
from databricks.sql.telemetry.latency_logger import log_latency
5457
from databricks.sql.telemetry.models.enums import DriverVolumeOperationType
5558

@@ -240,7 +243,9 @@ def read(self) -> Optional[OAuthToken]:
240243
self.telemetry_enabled = (
241244
self.client_telemetry_enabled and self.server_telemetry_enabled
242245
)
243-
telemetry_batch_size = kwargs.get("telemetry_batch_size", 100) # TODO: Decide on batch size
246+
telemetry_batch_size = kwargs.get(
247+
"telemetry_batch_size", 100
248+
) # TODO: Decide on batch size
244249

245250
user_agent_entry = kwargs.get("user_agent_entry")
246251
if user_agent_entry is None:
@@ -302,16 +307,16 @@ def read(self) -> Optional[OAuthToken]:
302307
host=self.host,
303308
connection_uuid=self.get_session_id_hex(),
304309
auth_provider=auth_provider,
305-
is_authenticated=True, # TODO: Add authentication logic later
310+
is_authenticated=True, # TODO: Add authentication logic later
306311
batch_size=telemetry_batch_size,
307312
user_agent=useragent_header,
308313
)
309-
314+
310315
telemetry_client.export_initial_telemetry_log(
311-
http_path,
312-
self.port,
316+
http_path,
317+
self.port,
313318
kwargs.get("_socket_timeout", None),
314-
self.get_session_id_hex()
319+
self.get_session_id_hex(),
315320
)
316321
else:
317322
self.telemetry_client = NoopTelemetryClient()
@@ -512,7 +517,10 @@ def __iter__(self):
512517
for row in self.active_result_set:
513518
yield row
514519
else:
515-
raise Error("There is no active result set", connection_uuid=self.connection.get_session_id_hex())
520+
raise Error(
521+
"There is no active result set",
522+
connection_uuid=self.connection.get_session_id_hex(),
523+
)
516524

517525
def _determine_parameter_approach(
518526
self, params: Optional[TParameterCollection]
@@ -649,7 +657,10 @@ def _close_and_clear_active_result_set(self):
649657

650658
def _check_not_closed(self):
651659
if not self.open:
652-
raise Error("Attempting operation on closed cursor", connection_uuid=self.connection.get_session_id_hex())
660+
raise Error(
661+
"Attempting operation on closed cursor",
662+
connection_uuid=self.connection.get_session_id_hex(),
663+
)
653664

654665
def _handle_staging_operation(
655666
self, staging_allowed_local_path: Union[None, str, List[str]]
@@ -668,7 +679,7 @@ def _handle_staging_operation(
668679
else:
669680
raise Error(
670681
"You must provide at least one staging_allowed_local_path when initialising a connection to perform ingestion commands",
671-
connection_uuid=self.connection.get_session_id_hex()
682+
connection_uuid=self.connection.get_session_id_hex(),
672683
)
673684

674685
abs_staging_allowed_local_paths = [
@@ -698,7 +709,7 @@ def _handle_staging_operation(
698709
if not allow_operation:
699710
raise Error(
700711
"Local file operations are restricted to paths within the configured staging_allowed_local_path",
701-
connection_uuid=self.connection.get_session_id_hex()
712+
connection_uuid=self.connection.get_session_id_hex(),
702713
)
703714

704715
# May be real headers, or could be json string
@@ -729,7 +740,7 @@ def _handle_staging_operation(
729740
raise Error(
730741
f"Operation {row.operation} is not supported. "
731742
+ "Supported operations are GET, PUT, and REMOVE",
732-
connection_uuid=self.connection.get_session_id_hex()
743+
connection_uuid=self.connection.get_session_id_hex(),
733744
)
734745

735746
@log_latency()
@@ -742,7 +753,10 @@ def _handle_staging_put(
742753
"""
743754

744755
if local_file is None:
745-
raise Error("Cannot perform PUT without specifying a local_file", connection_uuid=self.connection.get_session_id_hex())
756+
raise Error(
757+
"Cannot perform PUT without specifying a local_file",
758+
connection_uuid=self.connection.get_session_id_hex(),
759+
)
746760

747761
self.volume_operation_type = DriverVolumeOperationType.PUT
748762
self.volume_path = local_file
@@ -762,7 +776,8 @@ def _handle_staging_put(
762776

763777
if r.status_code not in [OK, CREATED, NO_CONTENT, ACCEPTED]:
764778
raise Error(
765-
f"Staging operation over HTTP was unsuccessful: {r.status_code}-{r.text}", connection_uuid=self.connection.get_session_id_hex()
779+
f"Staging operation over HTTP was unsuccessful: {r.status_code}-{r.text}",
780+
connection_uuid=self.connection.get_session_id_hex(),
766781
)
767782

768783
if r.status_code == ACCEPTED:
@@ -781,7 +796,10 @@ def _handle_staging_get(
781796
"""
782797

783798
if local_file is None:
784-
raise Error("Cannot perform GET without specifying a local_file", connection_uuid=self.connection.get_session_id_hex())
799+
raise Error(
800+
"Cannot perform GET without specifying a local_file",
801+
connection_uuid=self.connection.get_session_id_hex(),
802+
)
785803

786804
self.volume_operation_type = DriverVolumeOperationType.GET
787805
self.volume_path = local_file
@@ -792,7 +810,8 @@ def _handle_staging_get(
792810
# Any 2xx or 3xx will evaluate r.ok == True
793811
if not r.ok:
794812
raise Error(
795-
f"Staging operation over HTTP was unsuccessful: {r.status_code}-{r.text}", connection_uuid=self.connection.get_session_id_hex()
813+
f"Staging operation over HTTP was unsuccessful: {r.status_code}-{r.text}",
814+
connection_uuid=self.connection.get_session_id_hex(),
796815
)
797816

798817
with open(local_file, "wb") as fp:
@@ -805,7 +824,9 @@ def _handle_staging_remove(
805824
"""Make an HTTP DELETE request to the presigned_url"""
806825

807826
self.volume_operation_type = DriverVolumeOperationType.DELETE
808-
self.volume_path = presigned_url # Using presigned URL as path since there's no local file
827+
self.volume_path = (
828+
presigned_url # Using presigned URL as path since there's no local file
829+
)
809830

810831
r = requests.delete(url=presigned_url, headers=headers)
811832

@@ -1010,7 +1031,8 @@ def get_async_execution_result(self):
10101031
return self
10111032
else:
10121033
raise Error(
1013-
f"get_execution_result failed with Operation status {operation_state}", connection_uuid=self.connection.get_session_id_hex()
1034+
f"get_execution_result failed with Operation status {operation_state}",
1035+
connection_uuid=self.connection.get_session_id_hex(),
10141036
)
10151037

10161038
def executemany(self, operation, seq_of_parameters):
@@ -1160,7 +1182,10 @@ def fetchall(self) -> List[Row]:
11601182
if self.active_result_set:
11611183
return self.active_result_set.fetchall()
11621184
else:
1163-
raise Error("There is no active result set", connection_uuid=self.connection.get_session_id_hex())
1185+
raise Error(
1186+
"There is no active result set",
1187+
connection_uuid=self.connection.get_session_id_hex(),
1188+
)
11641189

11651190
def fetchone(self) -> Optional[Row]:
11661191
"""
@@ -1174,7 +1199,10 @@ def fetchone(self) -> Optional[Row]:
11741199
if self.active_result_set:
11751200
return self.active_result_set.fetchone()
11761201
else:
1177-
raise Error("There is no active result set", connection_uuid=self.connection.get_session_id_hex())
1202+
raise Error(
1203+
"There is no active result set",
1204+
connection_uuid=self.connection.get_session_id_hex(),
1205+
)
11781206

11791207
def fetchmany(self, size: int) -> List[Row]:
11801208
"""
@@ -1196,21 +1224,30 @@ def fetchmany(self, size: int) -> List[Row]:
11961224
if self.active_result_set:
11971225
return self.active_result_set.fetchmany(size)
11981226
else:
1199-
raise Error("There is no active result set", connection_uuid=self.connection.get_session_id_hex())
1227+
raise Error(
1228+
"There is no active result set",
1229+
connection_uuid=self.connection.get_session_id_hex(),
1230+
)
12001231

12011232
def fetchall_arrow(self) -> "pyarrow.Table":
12021233
self._check_not_closed()
12031234
if self.active_result_set:
12041235
return self.active_result_set.fetchall_arrow()
12051236
else:
1206-
raise Error("There is no active result set", connection_uuid=self.connection.get_session_id_hex())
1237+
raise Error(
1238+
"There is no active result set",
1239+
connection_uuid=self.connection.get_session_id_hex(),
1240+
)
12071241

12081242
def fetchmany_arrow(self, size) -> "pyarrow.Table":
12091243
self._check_not_closed()
12101244
if self.active_result_set:
12111245
return self.active_result_set.fetchmany_arrow(size)
12121246
else:
1213-
raise Error("There is no active result set", connection_uuid=self.connection.get_session_id_hex())
1247+
raise Error(
1248+
"There is no active result set",
1249+
connection_uuid=self.connection.get_session_id_hex(),
1250+
)
12141251

12151252
def cancel(self) -> None:
12161253
"""

src/databricks/sql/telemetry/models/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class DriverSystemConfiguration:
9797
runtime_name: str
9898
runtime_version: str
9999
runtime_vendor: str
100-
client_app_name: str
100+
client_app_name: Optional[str]
101101
locale_name: str
102102
driver_name: str
103103
char_set_encoding: str

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def getDriverSystemConfiguration(cls) -> DriverSystemConfiguration:
4747
os_name=platform.system(),
4848
os_version=platform.release(),
4949
os_arch=platform.machine(),
50-
client_app_name="unknown", # TODO: Add client app name
50+
client_app_name=None, # TODO: Add client app name
5151
locale_name=locale.getlocale()[0] or locale.getdefaultlocale()[0],
5252
char_set_encoding=sys.getdefaultencoding(),
5353
)

0 commit comments

Comments
 (0)