Skip to content

Commit

Permalink
Jupyter Extension - Support naming mounts for explore view (#9681)
Browse files Browse the repository at this point in the history
Adds a mapping of name to commit_uri for tracking mounts so that users
can name their mounts and fixes the bug involving
repos/projects/branches having the character `_`.

Also fixes a bug where repos with the same name in different projects
would not appear. This bug was caused by keying the mounts on repo name.
I have changed them to be keyed on repo URI to provide uniqueness
between different projects.

[INT-1170](https://pachyderm.atlassian.net/browse/INT-1170)

[INT-1170]:
https://pachyderm.atlassian.net/browse/INT-1170?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: Kevin Yang <kevin.yang@hpe.com>
  • Loading branch information
kevyang and Kevin Yang committed Jan 27, 2024
1 parent c6ee70d commit 09efeae
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 85 deletions.
34 changes: 25 additions & 9 deletions jupyter-extension/jupyterlab_pachyderm/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ async def put(self):
response = self.datum_manager.datum_state()
get_logger().debug(f"Mount datums: {response}")
self.finish(response)
except ValueError as e:
get_logger().error(
f"Error mounting datums with invalid input {body}", exc_info=True
)
raise tornado.web.HTTPError(
status_code=getattr(e, "code", 400),
reason=f"Error mounting datums with invalid input {body}: {e}.",
)
except Exception as e:
get_logger().error(
f"Error mounting datums with input {body}", exc_info=True
Expand Down Expand Up @@ -267,11 +275,13 @@ async def get(self, path):
raise tornado.web.HTTPError(400, "Content %r is invalid" % content)
content = bool(int(content))
pagination_marker = None
pagination_marker_uri = self.get_query_argument("pagination_marker", default=None)
pagination_marker_uri = self.get_query_argument(
"pagination_marker", default=None
)
if pagination_marker_uri:
pagination_marker = pfs.File.from_uri(pagination_marker_uri)
number = int(self.get_query_argument("number", default="100"))

model = self.pfs_manager.get(
path=path,
type=type,
Expand Down Expand Up @@ -308,7 +318,9 @@ async def get(self, path):
raise tornado.web.HTTPError(400, "Content %r is invalid" % content)
content = int(content)
pagination_marker = None
pagination_marker_uri = self.get_query_argument("pagination_marker", default=None)
pagination_marker_uri = self.get_query_argument(
"pagination_marker", default=None
)
if pagination_marker_uri:
pagination_marker = pfs.File.from_uri(pagination_marker_uri)
number = int(self.get_query_argument("number", default="100"))
Expand Down Expand Up @@ -387,7 +399,10 @@ async def put(self):
except RuntimeError as e:
get_logger().error(f"Error writing local config: {e}.", exc_info=True)

payload = {"cluster_status": cluster_status, "pachd_address": self.client.address}
payload = {
"cluster_status": cluster_status,
"pachd_address": self.client.address,
}
await self.finish(json.dumps(payload))

@tornado.web.authenticated
Expand All @@ -406,7 +421,6 @@ async def get(self):


class AuthLoginHandler(BaseHandler):

@tornado.web.authenticated
async def put(self):
try:
Expand All @@ -425,9 +439,9 @@ async def put(self):
# Usage of _replace method comes from urlparse documentation:
# https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse
# noinspection PyProtectedMember
oidc_response.login_url = urlparse(
oidc_response.login_url
)._replace(scheme='https').geturl()
oidc_response.login_url = (
urlparse(oidc_response.login_url)._replace(scheme="https").geturl()
)

response = oidc_response.to_json()
await self.finish(response)
Expand Down Expand Up @@ -565,7 +579,9 @@ async def put(self, path):


def write_config(
pachd_address: str, server_cas: Optional[bytes], session_token: Optional[str],
pachd_address: str,
server_cas: Optional[bytes],
session_token: Optional[str],
) -> None:
"""Writes the pachd_address/server_cas context to the local config file.
This will create a new config file if one does not exist.
Expand Down

0 comments on commit 09efeae

Please sign in to comment.