From 194af48002dce3aa48b6b89ebc1e039e8d9af5d8 Mon Sep 17 00:00:00 2001 From: ReiHashimoto <42664619+ReiHashimoto@users.noreply.github.com> Date: Mon, 15 Apr 2024 17:53:12 +0900 Subject: [PATCH] remove microscope libs from package --- pyproject.toml | 1 - studio/app/optinist/microscopes/ND2Reader.py | 7 +++++++ studio/app/optinist/microscopes/OIRReader.py | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ee18e3b10..aea225b4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,6 @@ include = [ "frontend/build/static/js/*", "frontend/build/static/media/*", "studio/app/optinist/core/nwb/nwb.yaml", - "studio/app/optinist/microscopes/libs.zip", "studio/app/common/core/snakemake/snakemake.yaml", "studio/app/*/wrappers/**/*.yaml", "studio/app/Snakefile", diff --git a/studio/app/optinist/microscopes/ND2Reader.py b/studio/app/optinist/microscopes/ND2Reader.py index 4b1929438..a5a1d1328 100644 --- a/studio/app/optinist/microscopes/ND2Reader.py +++ b/studio/app/optinist/microscopes/ND2Reader.py @@ -7,6 +7,7 @@ from enum import Enum, IntEnum import numpy as np +import requests from studio.app.dir_path import DIRPATH from studio.app.optinist.microscopes.MicroscopeDataReaderBase import ( @@ -64,6 +65,12 @@ class ND2Reader(MicroscopeDataReaderBase): def unpack_libs(): """Unpack library files""" if not os.path.isdir(DIRPATH.MICROSCOPE_LIB_DIR): + if not os.path.exists(DIRPATH.MICROSCOPE_LIB_ZIP): + response = requests.get( + "https://github.com/oist/optinist/raw/v1.2.1/studio/app/optinist/microscopes/libs.zip" # noqa: E501 + ) + with open(DIRPATH.MICROSCOPE_LIB_ZIP, "wb") as f: + f.write(response.content) shutil.unpack_archive( DIRPATH.MICROSCOPE_LIB_ZIP, DIRPATH.MICROSCOPE_LIB_DIR ) diff --git a/studio/app/optinist/microscopes/OIRReader.py b/studio/app/optinist/microscopes/OIRReader.py index 1b287f28b..36280c5ae 100644 --- a/studio/app/optinist/microscopes/OIRReader.py +++ b/studio/app/optinist/microscopes/OIRReader.py @@ -4,6 +4,7 @@ import shutil import numpy as np +import requests import studio.app.optinist.microscopes.modules.olympus.lib as lib from studio.app.dir_path import DIRPATH @@ -58,6 +59,13 @@ class OIRReader(MicroscopeDataReaderBase): def unpack_libs(): """Unpack library files""" if not os.path.isdir(DIRPATH.MICROSCOPE_LIB_DIR): + if not os.path.exists(DIRPATH.MICROSCOPE_LIB_ZIP): + response = requests.get( + "https://github.com/oist/optinist/raw/v1.2.1/studio/app/optinist/microscopes/libs.zip" # noqa: E501 + ) + with open(DIRPATH.MICROSCOPE_LIB_ZIP, "wb") as f: + f.write(response.content) + shutil.unpack_archive( DIRPATH.MICROSCOPE_LIB_ZIP, DIRPATH.MICROSCOPE_LIB_DIR )