diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 28d502c417828847fb035afec9c07d8ed50e2759..e6320b0cb445ad03f2efeed30f11ee1c7d614b9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,12 +66,12 @@ test-server-side-scripting: # Build a docker image in which tests for this repository can run build-testenv: tags: [ cached-dind ] - image: docker:19.03 + image: docker:27.3.1 stage: setup timeout: 3 h - only: - - web - - schedules + # only: + # - web + # - schedules script: - cd test/docker - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY diff --git a/CHANGELOG.md b/CHANGELOG.md index 881604778b77e981be8eb3721ec48594e03f2f03..a65e027f810c8ab8d503138b91090278ad9a98bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### +- [#254](https://gitlab.com/linkahead/linkahead-webui/-/issues/254) "Download files referenced in the table" failed + ### Security ### ### Documentation ### diff --git a/src/server_side_scripting/ext_file_download/zip_files.py b/src/server_side_scripting/ext_file_download/zip_files.py index 2ecfaa8c25b694c7de940cd03e9bf97196ce2b86..7f151d8bf28d89d3193d44665ae7a1645828255c 100755 --- a/src/server_side_scripting/ext_file_download/zip_files.py +++ b/src/server_side_scripting/ext_file_download/zip_files.py @@ -32,7 +32,7 @@ from zipfile import ZipFile import linkahead as db import pandas as pd -from linkaheadadvancedtools.serverside import helper +from caosadvancedtools.serverside import helper from linkahead import LinkAheadException, ConsistencyError, EntityDoesNotExistError @@ -71,9 +71,7 @@ def collect_files_in_zip(ids, table): # download and add all files for file_id in ids: try: - tmp = db.execute_query("FIND FILE WITH ID={a:}".format( - a=file_id), - unique=True) + tmp = db.get_entity_by_id(file_id, role="FILE") except EntityDoesNotExistError as e: # TODO # Current behavior: script terminates with error if just one @@ -81,14 +79,14 @@ def collect_files_in_zip(ids, table): # Desired behavior: The script should go on with the other # ids, but the user should be informed about the missing files. # How should we do this? - logger = logging.getLogger("linkaheadadvancedtools") - logger.error("Did not find Entity with ID={}.".format( + logger = logging.getLogger("caosadvancedtools") + logger.error("Did not find File with ID={}.".format( file_id)) raise e savename = nc.get_unique_savename(os.path.basename(tmp.path)) val_file = helper.get_file_via_download( - tmp, logger=logging.getLogger("linkaheadadvancedtools")) + tmp, logger=logging.getLogger("caosadvancedtools")) zf.write(val_file, savename) diff --git a/src/server_side_scripting/ext_table_preview/pandas_table_preview.py b/src/server_side_scripting/ext_table_preview/pandas_table_preview.py index 13c9b394648548bd6124de8a7318b18bb8a9221c..bc24201a121be056693963705373ed9e6ebe29f1 100755 --- a/src/server_side_scripting/ext_table_preview/pandas_table_preview.py +++ b/src/server_side_scripting/ext_table_preview/pandas_table_preview.py @@ -35,8 +35,8 @@ from datetime import datetime import linkahead as db import pandas as pd -from linkaheadadvancedtools.serverside.helper import get_argument_parser -from linkaheadadvancedtools.serverside.logging import configure_server_side_logging +from caosadvancedtools.serverside.helper import get_argument_parser +from caosadvancedtools.serverside.logging import configure_server_side_logging MAXIMUMFILESIZE = 1e8 VALID_ENDINGS = [".csv", ".tsv", ".xls", ".xlsx"] @@ -135,7 +135,7 @@ if __name__ == "__main__": args = parser.parse_args() debug_file = configure_server_side_logging() - logger = logging.getLogger("linkaheadadvancedtools") + logger = logging.getLogger("caosadvancedtools") db.configure_connection(auth_token=args.auth_token) entity_id = args.filename diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile index 6a14c5027171e80293504a33bb8ff5af5fec4bd8..d816f92fa3a7a529c55d0aaaafbaf30082f0a6da 100644 --- a/test/docker/Dockerfile +++ b/test/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:11 +FROM debian:12 ADD node_gpg.asc /etc/apt/ RUN apt-get update \ && apt-get install -y gnupg ca-certificates\ @@ -12,14 +12,15 @@ RUN apt-get update \ nodejs npm \ && apt-get install -f -RUN pip3 install pylint pytest +RUN pip3 install --break-system-packages pylint pytest +RUN pip3 install --break-system-packages sphinx-js sphinx-autoapi recommonmark sphinx-rtd-theme +RUN pip3 install --break-system-packages pandas + # TODO rename to linkahead -# RUN pip3 install caosdb>=0.7.4 -RUN pip3 install git+https://gitlab.com/caosdb/caosdb-pylib.git@f-linkahead-rename -RUN pip3 install pandas +RUN pip3 install --break-system-packages git+https://gitlab.com/caosdb/caosdb-pylib.git@dev # TODO rename to linkahead -RUN pip3 install git+https://gitlab.com/caosdb/caosdb-advanced-user-tools.git@f-linkahead-rename +RUN pip3 install --break-system-packages git+https://gitlab.com/caosdb/caosdb-advanced-user-tools.git@dev + # For automatic documentation # RUN npm install -g jsdoc # RUN npm install -g jsdoc-sphinx -RUN pip3 install sphinx-js sphinx-autoapi recommonmark sphinx-rtd-theme diff --git a/test/server_side_scripting/ext_file_download/test_zip_files.py b/test/server_side_scripting/ext_file_download/test_zip_files.py new file mode 100644 index 0000000000000000000000000000000000000000..d42b49b067705a6a91e6e4bba5258fd9db685d9b --- /dev/null +++ b/test/server_side_scripting/ext_file_download/test_zip_files.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# encoding: utf-8 +# +# This file is a part of the LinkAhead Project. +# +# Copyright (C) 2024 IndiScale GmbH <info@indiscale.com> +# Copyright (C) 2024 Daniel Hornung <d.hornung@indiscale.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# + +import os +import unittest + +import linkahead as db +from linkahead.common.models import _parse_single_xml_element +from lxml import etree +from zip_files import (collect_files_in_zip) + + +class ZipTest(unittest.TestCase): + pass diff --git a/test/server_side_scripting/ext_file_download/zip_files.py b/test/server_side_scripting/ext_file_download/zip_files.py new file mode 120000 index 0000000000000000000000000000000000000000..4f594ec180c19a84199da1f8a13efeefdb974d19 --- /dev/null +++ b/test/server_side_scripting/ext_file_download/zip_files.py @@ -0,0 +1 @@ +../../../src/server_side_scripting/ext_file_download/zip_files.py \ No newline at end of file diff --git a/test/server_side_scripting/ext_table_preview/requirements.txt b/test/server_side_scripting/ext_table_preview/requirements.txt index 828669fd56d10e7dda0e61917621f15c0fd057a8..d52075bbf03485c453582e876c046a27b35ce2bd 100644 --- a/test/server_side_scripting/ext_table_preview/requirements.txt +++ b/test/server_side_scripting/ext_table_preview/requirements.txt @@ -1,4 +1,4 @@ +linkahead # TODO rename to linkahead -caosdb caosadvancedtools pandas