Skip to content

Commit

Permalink
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 17, 2023
1 parent 7b9b311 commit 2c2e8b0
Show file tree
Hide file tree
Showing 36 changed files with 1,763 additions and 2,198 deletions.
12 changes: 5 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'UPDATE.md']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -90,22 +90,22 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "furo"
html_theme = 'furo'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
"sidebar_hide_name": True,
'sidebar_hide_name': True,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

html_logo = "_static/images/papermill.png"
html_logo = '_static/images/papermill.png'

# -- Options for HTMLHelp output ------------------------------------------

Expand All @@ -132,9 +132,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'papermill.tex', 'papermill Documentation', 'nteract team', 'manual')
]
latex_documents = [(master_doc, 'papermill.tex', 'papermill Documentation', 'nteract team', 'manual')]


# -- Options for manual page output ---------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions papermill/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .version import version as __version__

from .exceptions import PapermillException, PapermillExecutionError
from .execute import execute_notebook
from .inspection import inspect_notebook
from .version import version as __version__
2 changes: 1 addition & 1 deletion papermill/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from papermill.cli import papermill

if __name__ == "__main__":
if __name__ == '__main__':
papermill()
44 changes: 16 additions & 28 deletions papermill/abs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Utilities for working with Azure blob storage"""
import re
import io
import re

from azure.storage.blob import BlobServiceClient
from azure.identity import EnvironmentCredential
from azure.storage.blob import BlobServiceClient


class AzureBlobStore:
Expand All @@ -20,7 +20,7 @@ class AzureBlobStore:

def _blob_service_client(self, account_name, sas_token=None):
blob_service_client = BlobServiceClient(
account_url=f"{account_name}.blob.core.windows.net",
account_url=f'{account_name}.blob.core.windows.net',
credential=sas_token or EnvironmentCredential(),
)

Expand All @@ -32,50 +32,38 @@ def _split_url(self, url):
see: https://docs.microsoft.com/en-us/azure/storage/common/storage-dotnet-shared-access-signature-part-1 # noqa: E501
abs://myaccount.blob.core.windows.net/sascontainer/sasblob.txt?sastoken
"""
match = re.match(
r"abs://(.*)\.blob\.core\.windows\.net\/(.*?)\/([^\?]*)\??(.*)$", url
)
match = re.match(r'abs://(.*)\.blob\.core\.windows\.net\/(.*?)\/([^\?]*)\??(.*)$', url)
if not match:
raise Exception(f"Invalid azure blob url '{url}'")
else:
params = {
"account": match.group(1),
"container": match.group(2),
"blob": match.group(3),
"sas_token": match.group(4),
'account': match.group(1),
'container': match.group(2),
'blob': match.group(3),
'sas_token': match.group(4),
}
return params

def read(self, url):
"""Read storage at a given url"""
params = self._split_url(url)
output_stream = io.BytesIO()
blob_service_client = self._blob_service_client(
params["account"], params["sas_token"]
)
blob_client = blob_service_client.get_blob_client(
params["container"], params["blob"]
)
blob_service_client = self._blob_service_client(params['account'], params['sas_token'])
blob_client = blob_service_client.get_blob_client(params['container'], params['blob'])
blob_client.download_blob().readinto(output_stream)
output_stream.seek(0)
return [line.decode("utf-8") for line in output_stream]
return [line.decode('utf-8') for line in output_stream]

def listdir(self, url):
"""Returns a list of the files under the specified path"""
params = self._split_url(url)
blob_service_client = self._blob_service_client(
params["account"], params["sas_token"]
)
container_client = blob_service_client.get_container_client(params["container"])
return list(container_client.list_blobs(params["blob"]))
blob_service_client = self._blob_service_client(params['account'], params['sas_token'])
container_client = blob_service_client.get_container_client(params['container'])
return list(container_client.list_blobs(params['blob']))

def write(self, buf, url):
"""Write buffer to storage at a given url"""
params = self._split_url(url)
blob_service_client = self._blob_service_client(
params["account"], params["sas_token"]
)
blob_client = blob_service_client.get_blob_client(
params["container"], params["blob"]
)
blob_service_client = self._blob_service_client(params['account'], params['sas_token'])
blob_client = blob_service_client.get_blob_client(params['container'], params['blob'])
blob_client.upload_blob(data=buf, overwrite=True)
11 changes: 3 additions & 8 deletions papermill/adl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self):

@classmethod
def _split_url(cls, url):
match = re.match(r"adl://(.*)\.azuredatalakestore\.net\/(.*)$", url)
match = re.match(r'adl://(.*)\.azuredatalakestore\.net\/(.*)$', url)
if not match:
raise Exception(f"Invalid ADL url '{url}'")
else:
Expand All @@ -39,12 +39,7 @@ def listdir(self, url):
"""Returns a list of the files under the specified path"""
(store_name, path) = self._split_url(url)
adapter = self._create_adapter(store_name)
return [
"adl://{store_name}.azuredatalakestore.net/{path_to_child}".format(
store_name=store_name, path_to_child=path_to_child
)
for path_to_child in adapter.ls(path)
]
return [f'adl://{store_name}.azuredatalakestore.net/{path_to_child}' for path_to_child in adapter.ls(path)]

def read(self, url):
"""Read storage at a given url"""
Expand All @@ -60,5 +55,5 @@ def write(self, buf, url):
"""Write buffer to storage at a given url"""
(store_name, path) = self._split_url(url)
adapter = self._create_adapter(store_name)
with adapter.open(path, "wb") as f:
with adapter.open(path, 'wb') as f:
f.write(buf.encode())
Loading

0 comments on commit 2c2e8b0

Please sign in to comment.