Skip to content

Commit

Permalink
fix: boto3 import and other refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer committed Jan 20, 2024
1 parent 238a9d9 commit 51604dc
Show file tree
Hide file tree
Showing 3 changed files with 407 additions and 194 deletions.
12 changes: 7 additions & 5 deletions src/harlequin/components/data_catalog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import sys
from collections import defaultdict
from pathlib import Path
from typing import ClassVar, Generic, List, Set, Tuple, Union
Expand Down Expand Up @@ -28,7 +27,7 @@
try:
import boto3
except ImportError:
pass
boto3 = None # type: ignore


class DataCatalog(TabbedContent, can_focus=True):
Expand Down Expand Up @@ -110,10 +109,10 @@ def on_mount(self) -> None:
else:
self.file_tree = None

if self.show_s3 is not None and "boto3" in sys.modules:
if self.show_s3 is not None and boto3 is not None:
self.s3_tree: S3Tree | None = S3Tree(uri=self.show_s3)
self.add_pane(TabPane("s3", self.s3_tree))
elif self.show_s3 is not None and "boto3" not in sys.modules:
self.add_pane(TabPane("S3", self.s3_tree))
elif self.show_s3 is not None and boto3 is None:
self.post_message(
DataCatalog.CatalogError(
catalog_type="s3",
Expand Down Expand Up @@ -425,6 +424,9 @@ def reload(self) -> None:

@work(thread=True, exclusive=True, exit_on_error=False)
def _reload_objects(self) -> None:
if boto3 is None:
return

def recursive_dict() -> defaultdict:
return defaultdict(recursive_dict)

Expand Down
Loading

0 comments on commit 51604dc

Please sign in to comment.