Skip to content

Commit

Permalink
Rename things
Browse files Browse the repository at this point in the history
  • Loading branch information
sultaniman committed Mar 20, 2024
1 parent 0844570 commit e7e8473
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 10 additions & 3 deletions dlt/helpers/pypi.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import importlib
import subprocess
import sys
from types import ModuleType

from dlt.cli import echo as fmt
from dlt.common.exceptions import MissingDependencyException


class Installer:
class Importer:
@staticmethod
def install(package: str):
def import_module(caller: str, package: str) -> ModuleType:
if package not in sys.modules:
if Installer.yes_please(package):
if Importer.yes_please(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
else:
raise MissingDependencyException(caller, [package])

return importlib.import_module(package)

@staticmethod
def yes_please(package: str) -> bool:
Expand Down
13 changes: 3 additions & 10 deletions dlt/helpers/streamlit_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@
from dlt.common.utils import flatten_list_or_items

from dlt.common.libs.pandas import pandas
from dlt.helpers.pypi import Importer
from dlt.pipeline import Pipeline
from dlt.pipeline.exceptions import CannotRestorePipelineException, SqlClientNotAvailable
from dlt.pipeline.state_sync import load_pipeline_state_from_destination

try:
import streamlit as st

# from streamlit import SECRETS_FILE_LOC, secrets
except ModuleNotFoundError:
raise MissingDependencyException(
"DLT Streamlit Helpers",
["streamlit"],
"DLT Helpers for Streamlit should be run within a streamlit app.",
)
# type: streamlit
st = Importer.import_module("DLT Streamlit Helpers", "streamlit")


# use right caching function to disable deprecation message
Expand Down

0 comments on commit e7e8473

Please sign in to comment.