Skip to content

Commit

Permalink
✅ Update dependency check.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrikerMan committed Jul 4, 2021
1 parent b95bfb7 commit bc55c54
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
strategy:
matrix:
group: [ 1, 2, 3 ]
tensorflow_version: [2.2, 2.3, 2.4, 2.5]
tensorflow_version: [2.1, 2.2, 2.3, 2.4, 2.5]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
Expand Down
37 changes: 26 additions & 11 deletions kashgari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,40 @@
"""

import os
from typing import Dict, Any
from distutils.version import LooseVersion
from typing import Any, Dict

os.environ['TF_KERAS'] = '1'
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

custom_objects: Dict[str, Any] = {}

def check_tfa_version(tf_version):
if LooseVersion(tf_version) < '2.2.0':
return '0.9.1'
elif LooseVersion(tf_version) < '2.3.0':
return '0.11.2'
else:
return '0.13.0'


def dependency_check() -> None:
import tensorflow as tf
tfa_version = check_tfa_version(tf_version=tf.__version__)
try:
import tensorflow_addons as tfa
except:
raise ImportError(
"Kashgari request tensorflow_addons, please install via the "
f"`$pip install tensorflow_addons=={tfa_version}`"
)

dependency_check()

from kashgari import corpus, embeddings, layers, macros, processors, tasks, utils
from kashgari.__version__ import __version__
from kashgari.macros import config
from kashgari import layers
from kashgari import corpus
from kashgari import embeddings
from kashgari import macros
from kashgari import processors
from kashgari import tasks
from kashgari import utils

from kashgari.utils.dependency_check import dependency_check

custom_objects = layers.resigter_custom_layers(custom_objects)

dependency_check()

24 changes: 0 additions & 24 deletions kashgari/utils/dependency_check.py

This file was deleted.

0 comments on commit bc55c54

Please sign in to comment.