1
0
mirror of https://github.com/gsi-upm/senpy synced 2025-01-05 19:21:27 +00:00

Modify dependencies to allow for 3.7 compatibility

Some dependencies are not available for python 3.7 anymore. Instead
of trying to support different versions of the libraries, we opt to
focus on the latest python version, and allow for CORE functionality
for earlier versions.
This commit is contained in:
J. Fernando Sánchez 2023-09-26 18:52:04 +02:00
parent 3f227986f3
commit f3d4415ffb
8 changed files with 35 additions and 10 deletions

3
.gitignore vendored
View File

@ -7,4 +7,5 @@ README.html
__pycache__
VERSION
Dockerfile-*
Dockerfile
Dockerfile
senpy_data

View File

@ -7,12 +7,14 @@
stages:
- test
- publish
- test_image
- deploy
variables:
KUBENS: senpy
LATEST_IMAGE: "${HUB_REPO}:${CI_COMMIT_SHORT_SHA}"
SENPY_DATA: "/senpy-data/" # This is configured in the CI job
NLTK_DATA: "/senpy-data/nltk" # Store NLTK downloaded data
docker:
stage: publish
@ -51,18 +53,30 @@ docker-latest:
refs:
- master
testimage:
tags:
- docker
stage: test_image
image: "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
script:
- python -m senpy --no-run --test
testpy37:
tags:
- docker
variables:
SENPY_STRICT: "false"
image: python:3.7
stage: test
script:
- pip install -r requirements.txt -r test-requirements.txt -r extra-requirements.txt
- pip install -r requirements.txt -r test-requirements.txt
- python setup.py test
testpy310:
tags:
- docker
variables:
SENPY_STRICT: "true"
image: python:3.10
stage: test
script:
@ -74,7 +88,7 @@ push_pypi:
- tags
tags:
- docker
image: python:3.7
image: python:3.10
stage: publish
script:
- echo $CI_COMMIT_TAG > senpy/VERSION
@ -87,7 +101,7 @@ check_pypi:
- tags
tags:
- docker
image: python:3.7
image: python:3.10
stage: deploy
script:
- pip install senpy==$CI_COMMIT_TAG

View File

@ -58,7 +58,7 @@ Its code is pure Python, and the only limitations are imposed by its dependencie
Currently, the CI/CD pipeline tests the code on:
* GNU/Linux with Python versions 3.4, 3.5, 3.6 and 3.7
* GNU/Linux with Python versions 3.7+ (3.10+ recommended for all plugins)
* MacOS and homebrew's python3
* Windows 10 and chocolatey's python3

View File

@ -2,5 +2,5 @@ gsitk>0.1.9.1
flask_cors==3.0.10
Pattern==3.6
lxml==4.9.3
pandas~=2
pandas==2.1.1
textblob==0.17.1

View File

@ -23,6 +23,7 @@ from flask import Flask
from senpy.extensions import Senpy
from senpy.utils import easy_test
from senpy.plugins import list_dependencies
from senpy import config
import logging
import os
@ -95,7 +96,7 @@ def main():
parser.add_argument(
'--strict',
action='store_true',
default=False,
default=config.strict,
help='Fail if optional plugins cannot be loaded.')
parser.add_argument(
'--test',

7
senpy/config.py Normal file
View File

@ -0,0 +1,7 @@
import os
strict = os.environ.get('SENPY_STRICT', '').lower() not in ["", "false", "f"]
data_folder = os.environ.get('SENPY_DATA', None)
if data_folder:
data_folder = os.path.abspath(data_folder)
testing = os.environ.get('SENPY_TESTING', "") != ""

View File

@ -46,6 +46,7 @@ from .. import models, utils
from .. import api
from .. import gsitk_compat
from .. import testing
from .. import config
logger = logging.getLogger(__name__)
@ -75,7 +76,7 @@ class PluginMeta(models.BaseMeta):
cls = super(PluginMeta, mcs).__new__(mcs, name, bases, attrs)
if alias in mcs._classes:
if os.environ.get('SENPY_TESTING', ""):
if config.testing:
raise Exception(
('The type of plugin {} already exists. '
'Please, choose a different name').format(name))
@ -123,7 +124,7 @@ class Plugin(with_metaclass(PluginMeta, models.Plugin)):
os.path.dirname(inspect.getfile(self.__class__)))
if not data_folder:
data_folder = os.environ['SENPY_DATA']
data_folder = config.data_folder
if not data_folder:
data_folder = os.getcwd()

View File

@ -27,6 +27,7 @@ from senpy.models import Results, Entry, EmotionSet, Emotion, Plugins
from senpy import plugins
from senpy.plugins.postprocessing.emotion.centroids import CentroidConversion
from senpy.gsitk_compat import GSITK_AVAILABLE
from senpy import config
import pandas as pd
@ -386,7 +387,7 @@ class PluginsTest(TestCase):
def make_mini_test(fpath):
def mini_test(self):
for plugin in plugins.from_path(fpath, install=True):
for plugin in plugins.from_path(fpath, install=True, strict=config.strict):
plugin.test()
return mini_test