Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dbutils type stubs consistent with runtime implementation #196

Merged
merged 2 commits into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 57 additions & 23 deletions databricks/sdk/runtime/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,29 @@ def showRoles() -> typing.List[str]:
"""
...

@staticmethod
def getCurrentCredentials() -> typing.Mapping[str, str]:
...

class data:
"""
Utilities for understanding and interacting with datasets (EXPERIMENTAL)
"""

@staticmethod
def summarize(df: any, precise: bool) -> None:
"""
Summarize a Spark DataFrame and visualize the statistics to get quick insights
def summarize(df: any, precise: bool = False) -> None:
"""Summarize a Spark/pandas/Koalas DataFrame and visualize the statistics to get quick insights.

Example: dbutils.data.summarize(df)

:param df: A pyspark.sql.DataFrame, pyspark.pandas.DataFrame, databricks.koalas.DataFrame
or pandas.DataFrame object to summarize. Streaming dataframes are not supported.
:param precise: If false, percentiles, distinct item counts, and frequent item counts
will be computed approximately to reduce the run time.
If true, distinct item counts and frequent item counts will be computed exactly,
and percentiles will be computed with high precision.

:return: visualization of the computed summmary statistics.
"""
...

Expand All @@ -115,21 +129,21 @@ class fs:
"""

@staticmethod
def cp(from_: str, to: str, recurse: bool = False) -> bool:
def cp(source: str, dest: str, recurse: bool = False) -> bool:
"""
Copies a file or directory, possibly across FileSystems
"""
...

@staticmethod
def head(file: str, maxBytes: int = 65536) -> str:
def head(file: str, max_bytes: int = 65536) -> str:
"""
Returns up to the first 'maxBytes' bytes of the given file as a String encoded in UTF-8
"""
...

@staticmethod
def ls(dir: str) -> typing.List[FileInfo]:
def ls(path: str) -> typing.List[FileInfo]:
"""
Lists the contents of a directory
"""
Expand All @@ -143,7 +157,7 @@ def mkdirs(dir: str) -> bool:
...

@staticmethod
def mv(from_: str, to: str, recurse: bool = False) -> bool:
def mv(source: str, dest: str, recurse: bool = False) -> bool:
"""
Moves a file or directory, possibly across FileSystems
"""
Expand All @@ -164,30 +178,39 @@ def rm(dir: str, recurse: bool = False) -> bool:
...

@staticmethod
def mount(source: str,
mountPoint: str,
encryptionType: str = "",
owner: str = "",
extraConfigs: typing.Mapping[str, str] = None,
) -> bool:
"""
Mounts the given source directory into DBFS at the given mount point
"""
def cacheFiles(*files):
...

@staticmethod
def cacheTable(name: str):
...

@staticmethod
def unmount(mountPoint: str) -> bool:
def uncacheFiles(*files):
...

@staticmethod
def uncacheTable(name: str):
...

@staticmethod
def mount(source: str,
mount_point: str,
encryption_type: str = "",
owner: typing.Optional[str] = None,
extra_configs: typing.Mapping[str, str] = {},
) -> bool:
"""
Deletes a DBFS mount point
Mounts the given source directory into DBFS at the given mount point
"""
...

@staticmethod
def updateMount(source: str,
mountPoint: str,
encryptionType: str = "",
owner: str = "",
extraConfigs: typing.Map[str, str] = {},
mount_point: str,
encryption_type: str = "",
owner: typing.Optional[str] = None,
extra_configs: typing.Map[str, str] = {},
) -> bool:
"""
Similar to mount(), but updates an existing mount point (if present) instead of creating a new one
Expand All @@ -208,6 +231,13 @@ def refreshMounts() -> bool:
"""
...

@staticmethod
def unmount(mount_point: str) -> bool:
"""
Deletes a DBFS mount point
"""
...

class jobs:
"""
Utilities for leveraging jobs features
Expand Down Expand Up @@ -257,7 +287,7 @@ def exit(value: str) -> None:
...

@staticmethod
def run(path: str, timeoutSeconds: int, arguments: typing.Map[str, str]) -> str:
def run(path: str, timeout_seconds: int, arguments: typing.Map[str, str]) -> str:
"""
This method runs a notebook and returns its exit value
"""
Expand All @@ -275,6 +305,10 @@ def get(scope: str, key: str) -> str:
"""
...

@staticmethod
def getBytes(self, scope: str, key: str) -> bytes:
"""Gets the bytes representation of a secret value for the specified scope and key."""

@staticmethod
def list(scope: str) -> typing.List[SecretMetadata]:
"""
Expand Down