Skip to content

Commit

Permalink
fixed per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kovalsky committed Sep 5, 2024
1 parent e56a21c commit 3593025
Showing 1 changed file with 3 additions and 32 deletions.
35 changes: 3 additions & 32 deletions src/sempy_labs/_clear_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ def list_backups(workspace: Optional[str] = None) -> pd.DataFrame:
A pandas dataframe showing a list of backup files contained within a workspace's ADLS Gen2 storage account.
"""

from sempy_labs._helper_functions import get_adls_client

client = fabric.PowerBIRestClient()
workspace = fabric.resolve_workspace_name(workspace)
workspace_id = fabric.resolve_workspace_id(workspace)
Expand All @@ -278,36 +276,9 @@ def list_backups(workspace: Optional[str] = None) -> pd.DataFrame:
)
storage_account = v[0]["resourceName"]

df = pd.DataFrame(
columns=[
"Storage Account Name",
"File Path",
"File Size",
"Creation Time",
"Last Modified",
"Expiry Time",
"Encryption Scope",
]
)

onelake = get_adls_client(storage_account)
fs = onelake.get_file_system_client("power-bi-backup")

for x in list(fs.get_paths()):
if not x.is_directory:
new_data = {
"Storage Account Name": storage_account,
"File Path": x.name,
"File Size": x.content_length,
"Creation Time": x.creation_time,
"Last Modified": x.last_modified,
"Expiry Time": x.expiry_time,
"Encryption Scope": x.encryption_scope,
}

df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)

df["File Size"] = df["File Size"].astype(int)
df = list_storage_account_files(storage_account=storage_account)
colName = "Storage Account Name"
df.insert(0, colName, df.pop(colName))

return df

Expand Down

0 comments on commit 3593025

Please sign in to comment.