Skip to content

Commit

Permalink
using bert/version.py for setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kpe committed Jul 30, 2019
1 parent e3f61bd commit 90d3169
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -19,7 +19,7 @@ install:
- pip install --upgrade pip setuptools
- pip install 'tensorflow >= 1.14.0'
- pip install -r requirements.txt
- pip install coverage pep8 nose nose-exclude
- pip install -r requirements-dev.txt

# command to run tests
# require 100% coverage (not including test files) to pass Travis CI test
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
@@ -1,4 +1,3 @@
include requirements-dev.txt
include requirements.txt
include README.rst
include version
3 changes: 2 additions & 1 deletion bert/__init__.py
Expand Up @@ -4,10 +4,11 @@
#
from __future__ import division, absolute_import, print_function

from .version import __version__

from .attention import AttentionLayer
from .layer import Layer
from .model import BertModelLayer

from .loader import StockBertConfig, load_stock_weights, params_from_pretrained_ckpt
from .tokenization import FullTokenizer

1 change: 1 addition & 0 deletions bert/version.py
@@ -0,0 +1 @@
__version__ = "0.3.5"
13 changes: 10 additions & 3 deletions setup.py
Expand Up @@ -4,11 +4,18 @@
# created by kpe on 22.10.2018 at 11:46
#

from setuptools import setup, find_packages
from setuptools import setup, find_packages, convert_path


with open("version", "r") as fh:
__version__ = fh.read().strip()
def _version():
ns = {}
with open(convert_path("bert/version.py"), "r") as fh:
exec(fh.read(), ns)
return ns['__version__']


__version__ = _version()


with open("README.rst", "r") as fh:
long_description = fh.read()
Expand Down
25 changes: 25 additions & 0 deletions tests/test_attention.py
@@ -0,0 +1,25 @@
# coding=utf-8
#
# created by kpe on 30.Jul.2019 at 16:41
#

from __future__ import absolute_import, division, print_function


import unittest

import bert

import tensorflow as tf

tf.enable_eager_execution()


class TestAttention(unittest.TestCase):

def test_attention(self):
am = bert.AttentionLayer.create_attention_mask(from_shape=[2, 3, 5], # B,S,..
input_mask=[[2], [1]] # B,seq_len
)
print(am) # [batch_size, from_seq_len, seq_len]

1 change: 0 additions & 1 deletion version

This file was deleted.

0 comments on commit 90d3169

Please sign in to comment.