mirror of
https://github.com/gsi-upm/senpy
synced 2024-11-22 00:02:28 +00:00
Fix installation
* Remove '--use-wheel' flag * Remove pip dependency * Make GSITK an optional dependency
This commit is contained in:
parent
c0aa7ddc3c
commit
da4b11e5b5
@ -21,8 +21,8 @@ ONBUILD WORKDIR /senpy-plugins/
|
|||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY test-requirements.txt requirements.txt /usr/src/app/
|
COPY test-requirements.txt requirements.txt /usr/src/app/
|
||||||
RUN pip install --no-cache-dir --use-wheel -r test-requirements.txt -r requirements.txt
|
RUN pip install --no-cache-dir -r test-requirements.txt -r requirements.txt
|
||||||
COPY . /usr/src/app/
|
COPY . /usr/src/app/
|
||||||
RUN pip install --no-cache-dir --no-index --no-deps --editable .
|
RUN pip install --no-cache-dir --editable '/usr/src/app[evaluation]'
|
||||||
|
|
||||||
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
||||||
|
@ -17,15 +17,19 @@ import copy
|
|||||||
import errno
|
import errno
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from gsitk.datasets.datasets import DatasetManager
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from gsitk.datasets.datasets import DatasetManager
|
||||||
|
GSITK_AVAILABLE = True
|
||||||
|
except ImportError:
|
||||||
|
logger.warn('GSITK is not installed. Some functions will be unavailable.')
|
||||||
|
GSITK_AVAILABLE = False
|
||||||
|
|
||||||
|
|
||||||
class Senpy(object):
|
class Senpy(object):
|
||||||
""" Default Senpy extension for Flask """
|
""" Default Senpy extension for Flask """
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
app=None,
|
app=None,
|
||||||
plugin_folder=".",
|
plugin_folder=".",
|
||||||
@ -44,7 +48,6 @@ class Senpy(object):
|
|||||||
|
|
||||||
self._default = None
|
self._default = None
|
||||||
self._plugins = {}
|
self._plugins = {}
|
||||||
self._dm = DatasetManager()
|
|
||||||
if plugin_folder:
|
if plugin_folder:
|
||||||
self.add_folder(plugin_folder)
|
self.add_folder(plugin_folder)
|
||||||
|
|
||||||
@ -200,13 +203,17 @@ class Senpy(object):
|
|||||||
raise Error(
|
raise Error(
|
||||||
status=404,
|
status=404,
|
||||||
message="The dataset '{}' is not valid".format(dataset))
|
message="The dataset '{}' is not valid".format(dataset))
|
||||||
datasets = self._dm.prepare_datasets(datasets_name)
|
dm = DatasetManager()
|
||||||
|
datasets = dm.prepare_datasets(datasets_name)
|
||||||
return datasets
|
return datasets
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def datasets(self):
|
def datasets(self):
|
||||||
|
if not GSITK_AVAILABLE:
|
||||||
|
raise Exception('GSITK is not available. Install it to use this function.')
|
||||||
self._dataset_list = {}
|
self._dataset_list = {}
|
||||||
for item in self._dm.get_datasets():
|
dm = DatasetManager()
|
||||||
|
for item in dm.get_datasets():
|
||||||
for key in item:
|
for key in item:
|
||||||
if key in self._dataset_list:
|
if key in self._dataset_list:
|
||||||
continue
|
continue
|
||||||
@ -216,7 +223,8 @@ class Senpy(object):
|
|||||||
return self._dataset_list
|
return self._dataset_list
|
||||||
|
|
||||||
def evaluate(self, params):
|
def evaluate(self, params):
|
||||||
|
if not GSITK_AVAILABLE:
|
||||||
|
raise Exception('GSITK is not available. Install it to use this function.')
|
||||||
logger.debug("evaluating request: {}".format(params))
|
logger.debug("evaluating request: {}".format(params))
|
||||||
results = AggregatedEvaluation()
|
results = AggregatedEvaluation()
|
||||||
results.parameters = params
|
results.parameters = params
|
||||||
|
@ -19,16 +19,22 @@ import importlib
|
|||||||
import yaml
|
import yaml
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
from .. import models, utils
|
from .. import models, utils
|
||||||
from .. import api
|
from .. import api
|
||||||
|
|
||||||
from gsitk.evaluation.evaluation import Evaluation as Eval
|
|
||||||
from sklearn.pipeline import Pipeline
|
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from gsitk.evaluation.evaluation import Evaluation as Eval
|
||||||
|
from sklearn.pipeline import Pipeline
|
||||||
|
GSITK_AVAILABLE = True
|
||||||
|
except ImportError:
|
||||||
|
logger.warn('GSITK is not installed. Some functions will be unavailable.')
|
||||||
|
GSITK_AVAILABLE = False
|
||||||
|
|
||||||
|
|
||||||
class PluginMeta(models.BaseMeta):
|
class PluginMeta(models.BaseMeta):
|
||||||
_classes = {}
|
_classes = {}
|
||||||
@ -461,7 +467,7 @@ def install_deps(*plugins):
|
|||||||
for info in plugins:
|
for info in plugins:
|
||||||
requirements = info.get('requirements', [])
|
requirements = info.get('requirements', [])
|
||||||
if requirements:
|
if requirements:
|
||||||
pip_args = [sys.executable, '-m', 'pip', 'install', '--use-wheel']
|
pip_args = [sys.executable, '-m', 'pip', 'install']
|
||||||
for req in requirements:
|
for req in requirements:
|
||||||
pip_args.append(req)
|
pip_args.append(req)
|
||||||
logger.info('Installing requirements: ' + str(requirements))
|
logger.info('Installing requirements: ' + str(requirements))
|
||||||
@ -586,6 +592,9 @@ def _from_loaded_module(module, info=None, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def evaluate(plugins, datasets, **kwargs):
|
def evaluate(plugins, datasets, **kwargs):
|
||||||
|
if not GSITK_AVAILABLE:
|
||||||
|
raise Exception('GSITK is not available. Install it to use this function.')
|
||||||
|
|
||||||
ev = Eval(tuples=None,
|
ev = Eval(tuples=None,
|
||||||
datasets=datasets,
|
datasets=datasets,
|
||||||
pipelines=[plugin.as_pipe() for plugin in plugins])
|
pipelines=[plugin.as_pipe() for plugin in plugins])
|
||||||
|
22
setup.py
22
setup.py
@ -1,23 +1,19 @@
|
|||||||
import pip
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
# parse_requirements() returns generator of pip.req.InstallRequirement objects
|
|
||||||
from pip.req import parse_requirements
|
|
||||||
|
|
||||||
with open('senpy/VERSION') as f:
|
with open('senpy/VERSION') as f:
|
||||||
__version__ = f.read().strip()
|
__version__ = f.read().strip()
|
||||||
assert __version__
|
assert __version__
|
||||||
|
|
||||||
try:
|
|
||||||
install_reqs = parse_requirements(
|
|
||||||
"requirements.txt", session=pip.download.PipSession())
|
|
||||||
test_reqs = parse_requirements(
|
|
||||||
"test-requirements.txt", session=pip.download.PipSession())
|
|
||||||
except AttributeError:
|
|
||||||
install_reqs = parse_requirements("requirements.txt")
|
|
||||||
test_reqs = parse_requirements("test-requirements.txt")
|
|
||||||
|
|
||||||
install_reqs = [str(ir.req) for ir in install_reqs]
|
def parse_requirements(filename):
|
||||||
test_reqs = [str(ir.req) for ir in test_reqs]
|
""" load requirements from a pip requirements file """
|
||||||
|
with open(filename, 'r') as f:
|
||||||
|
lineiter = list(line.strip() for line in f)
|
||||||
|
return [line for line in lineiter if line and not line.startswith("#")]
|
||||||
|
|
||||||
|
|
||||||
|
install_reqs = parse_requirements("requirements.txt")
|
||||||
|
test_reqs = parse_requirements("test-requirements.txt")
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
Loading…
Reference in New Issue
Block a user