Skip to content

Commit

Permalink
Revert "Merge branch 'master' of github.com:mo-fu/Annif into mo-fu-ma…
Browse files Browse the repository at this point in the history
…ster"

This reverts commit aa96ebc, reversing
changes made to eb437a8.
  • Loading branch information
juhoinkinen committed Mar 9, 2023
1 parent 894eab3 commit b5a25f4
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 634 deletions.
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.8-slim-bullseye
LABEL maintainer="Juho Inkinen <juho.inkinen@helsinki.fi>"
SHELL ["/bin/bash", "-c"]

ARG optional_dependencies="fasttext voikko fasttext nn omikuji yake spacy pecos"
ARG optional_dependencies="fasttext voikko fasttext nn omikuji yake spacy"
ARG POETRY_VIRTUALENVS_CREATE=false

# Install system dependencies needed at runtime:
Expand Down Expand Up @@ -37,10 +37,6 @@ RUN if [[ $optional_dependencies =~ "spacy" ]]; then \
python -m spacy download $model; \
done; \
fi
RUN if [[ $optional_dependencies =~ "pecos" ]]; then \
mkdir /.cache -m a=rwx; \
fi


# Second round of installation with the actual code:
COPY annif /Annif/annif
Expand Down
12 changes: 0 additions & 12 deletions annif/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ def _tfidf():
return tfidf.TFIDFBackend


def _xtransformer():
try:
from . import xtransformer

return xtransformer.XTransformerBackend
except ImportError:
raise ValueError(
"XTransformer not available, not enabling XTransformer backend"
)


def _yake():
try:
from . import yake
Expand All @@ -112,7 +101,6 @@ def _yake():
"stwfsa": _stwfsa,
"svc": _svc,
"tfidf": _tfidf,
"xtransformer": _xtransformer,
"yake": _yake,
}

Expand Down
6 changes: 5 additions & 1 deletion annif/backend/fasttext.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ def _create_model(self, params, jobs):
self.info("creating fastText model")
trainpath = os.path.join(self.datadir, self.TRAIN_FILE)
modelpath = os.path.join(self.datadir, self.MODEL_FILE)
params = annif.util.apply_param_parse_config(self.FASTTEXT_PARAMS, params)
params = {
param: self.FASTTEXT_PARAMS[param](val)
for param, val in params.items()
if param in self.FASTTEXT_PARAMS
}
if jobs != 0: # jobs set by user to non-default value
params["thread"] = jobs
self.debug("Model parameters: {}".format(params))
Expand Down
5 changes: 4 additions & 1 deletion annif/backend/omikuji.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Annif backend using the Omikuji classifier"""

import os.path
import shutil

import omikuji

Expand Down Expand Up @@ -99,7 +100,9 @@ def _create_model(self, params, jobs):
hyper_param.collapse_every_n_layers = int(params["collapse_every_n_layers"])

self._model = omikuji.Model.train_on_data(train_path, hyper_param, jobs or None)
annif.util.atomic_save_folder(self._model, model_path)
if os.path.exists(model_path):
shutil.rmtree(model_path)
self._model.save(os.path.join(self.datadir, self.MODEL_FILE))

def _train(self, corpus, params, jobs=0):
if corpus != "cached":
Expand Down
8 changes: 6 additions & 2 deletions annif/backend/stwfsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from annif.exception import NotInitializedException, NotSupportedException
from annif.suggestion import ListSuggestionResult, SubjectSuggestion
from annif.util import apply_param_parse_config, atomic_save, boolean
from annif.util import atomic_save, boolean

from . import backend

Expand Down Expand Up @@ -95,7 +95,11 @@ def _load_data(self, corpus):

def _train(self, corpus, params, jobs=0):
X, y = self._load_data(corpus)
new_params = apply_param_parse_config(self.STWFSA_PARAMETERS, params)
new_params = {
key: self.STWFSA_PARAMETERS[key](val)
for key, val in params.items()
if key in self.STWFSA_PARAMETERS
}
p = StwfsapyPredictor(
graph=self.project.vocab.as_graph(),
langs=frozenset([params["language"]]),
Expand Down
237 changes: 0 additions & 237 deletions annif/backend/xtransformer.py

This file was deleted.

Loading

1 comment on commit b5a25f4

@juhoinkinen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reverted commits were pushed by accident to master. They were intended to be pushed to the branch of PR #540 when trying to reopen the PR.

Please sign in to comment.