diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 4075444a9..3cb063e47 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -11,6 +11,16 @@ ARG LANGUAGE="en" ARG PIP_INDEX_URL="https://pypi.org/simple" ENV PIP_INDEX_URL=$PIP_INDEX_URL +RUN pip3 install --upgrade pip -i $PIP_INDEX_URL \ + && (if [ "${LANGUAGE}" = "zh" ]; \ + # language is zh, download zh_core_web_sm from github + then wget https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.5.0/zh_core_web_sm-3.5.0-py3-none-any.whl -O /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \ + && pip3 install /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl -i $PIP_INDEX_URL \ + && rm /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl; \ + # not zh, download directly + else python3 -m spacy download zh_core_web_sm; \ + fi;) + RUN mkdir -p /app # COPY only requirements.txt first to leverage Docker cache @@ -29,21 +39,11 @@ WORKDIR /app # && pip3 install -r /tmp/requirements.txt -i $PIP_INDEX_URL --no-cache-dir \ # && rm /tmp/requirements.txt -RUN pip3 install --upgrade pip -i $PIP_INDEX_URL \ - && cd /app && pip3 install -i $PIP_INDEX_URL . +RUN pip3 install -i $PIP_INDEX_URL . # ENV CMAKE_ARGS="-DLLAMA_CUBLAS=ON -DLLAMA_AVX2=OFF -DLLAMA_F16C=OFF -DLLAMA_FMA=OFF" # ENV FORCE_CMAKE=1 -RUN cd /app && pip3 install -i $PIP_INDEX_URL .[llama_cpp] - -RUN (if [ "${LANGUAGE}" = "zh" ]; \ - # language is zh, download zh_core_web_sm from github - then wget https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.5.0/zh_core_web_sm-3.5.0-py3-none-any.whl -O /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \ - && pip3 install /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl -i $PIP_INDEX_URL \ - && rm /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl; \ - # not zh, download directly - else python3 -m spacy download zh_core_web_sm; \ - fi;) \ +RUN pip3 install -i $PIP_INDEX_URL .[llama_cpp] \ && rm -rf `pip3 cache dir` ARG BUILD_LOCAL_CODE="false" diff --git a/pilot/connections/rdbms/conn_sqlite.py b/pilot/connections/rdbms/conn_sqlite.py index 339af025a..1740537cf 100644 --- a/pilot/connections/rdbms/conn_sqlite.py +++ b/pilot/connections/rdbms/conn_sqlite.py @@ -70,10 +70,10 @@ class SQLiteConnect(RDBMSDatabase): def _sync_tables_from_db(self) -> Iterable[str]: table_results = self.session.execute( - "SELECT name FROM sqlite_master WHERE type='table'" + text("SELECT name FROM sqlite_master WHERE type='table'") ) view_results = self.session.execute( - "SELECT name FROM sqlite_master WHERE type='view'" + text("SELECT name FROM sqlite_master WHERE type='view'") ) table_results = set(row[0] for row in table_results) view_results = set(row[0] for row in view_results) diff --git a/pilot/connections/rdbms/tests/test_conn_sqlite.py b/pilot/connections/rdbms/tests/test_conn_sqlite.py index efe4ddf76..01ef51878 100644 --- a/pilot/connections/rdbms/tests/test_conn_sqlite.py +++ b/pilot/connections/rdbms/tests/test_conn_sqlite.py @@ -121,3 +121,17 @@ def test_get_database_list(db): def test_get_database_names(db): db.get_database_names() == [] + + +def test_db_dir_exist_dir(): + with tempfile.TemporaryDirectory() as temp_dir: + new_dir = os.path.join(temp_dir, "new_dir") + file_path = os.path.join(new_dir, "sqlite.db") + db = SQLiteConnect.from_file_path(file_path) + assert os.path.exists(new_dir) == True + assert list(db.get_table_names()) == [] + with tempfile.TemporaryDirectory() as existing_dir: + file_path = os.path.join(existing_dir, "sqlite.db") + db = SQLiteConnect.from_file_path(file_path) + assert os.path.exists(existing_dir) == True + assert list(db.get_table_names()) == []