Skip to content

Commit 694d6d9

Browse files
authored
Update CI for modern TensorFlow support (#549)
## Summary - Split CI coverage across TensorFlow 1.x and 2.x workflows, with TF1 staying on TensorFlow 1.15.5 and TF2 covering modern Python/TensorFlow combinations. - Add Codecov uploads and terminal missing-line coverage output so CI logs show which files are lowering coverage. - Replace private `tensorflow.python.keras` imports with public `tensorflow.keras` imports for better TensorFlow 2.x compatibility. - Update package/docs metadata for the 0.9.4 release and supported Python versions. ## Notes - `deepctr/estimator` remains supported primarily through the TensorFlow 1.15.5 workflow; modern TensorFlow 2.16+ removes `tf.estimator`.
1 parent e8f4d81 commit 694d6d9

55 files changed

Lines changed: 240 additions & 280 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 36 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,60 @@
1-
name: CI_TF2
1+
name: CI_TF1
22

33
on:
44
push:
5-
path:
6-
- 'deepctr/*'
7-
- 'tests/*'
5+
paths:
6+
- 'deepctr/**'
7+
- 'tests/**'
8+
- 'setup.py'
9+
- 'setup.cfg'
10+
- '.github/workflows/**'
811
pull_request:
9-
path:
10-
- 'deepctr/*'
11-
- 'tests/*'
12+
paths:
13+
- 'deepctr/**'
14+
- 'tests/**'
15+
- 'setup.py'
16+
- 'setup.cfg'
17+
- '.github/workflows/**'
18+
workflow_dispatch:
1219

1320
jobs:
1421
build:
15-
16-
runs-on: ubuntu-latest
17-
timeout-minutes: 180
22+
runs-on: ubuntu-22.04
23+
timeout-minutes: 240
1824
strategy:
25+
fail-fast: false
1926
matrix:
20-
python-version: [ 3.6,3.7,3.8, 3.9,3.10.7 ]
21-
tf-version: [ 2.6.0,2.7.0,2.8.0,2.9.0,2.10.0 ]
27+
include:
28+
- python-version: "3.7"
29+
tf-version: "1.15.5"
2230

23-
exclude:
24-
- python-version: 3.7
25-
tf-version: 1.4.0
26-
- python-version: 3.7
27-
tf-version: 1.15.0
28-
- python-version: 3.8
29-
tf-version: 1.4.0
30-
- python-version: 3.8
31-
tf-version: 1.14.0
32-
- python-version: 3.8
33-
tf-version: 1.15.0
34-
- python-version: 3.6
35-
tf-version: 2.7.0
36-
- python-version: 3.6
37-
tf-version: 2.8.0
38-
- python-version: 3.6
39-
tf-version: 2.9.0
40-
- python-version: 3.6
41-
tf-version: 2.10.0
42-
- python-version: 3.9
43-
tf-version: 1.4.0
44-
- python-version: 3.9
45-
tf-version: 1.15.0
46-
- python-version: 3.9
47-
tf-version: 2.2.0
48-
- python-version: 3.9
49-
tf-version: 2.5.0
50-
- python-version: 3.9
51-
tf-version: 2.6.0
52-
- python-version: 3.9
53-
tf-version: 2.7.0
54-
- python-version: 3.10.7
55-
tf-version: 1.4.0
56-
- python-version: 3.10.7
57-
tf-version: 1.15.0
58-
- python-version: 3.10.7
59-
tf-version: 2.2.0
60-
- python-version: 3.10.7
61-
tf-version: 2.5.0
62-
- python-version: 3.10.7
63-
tf-version: 2.6.0
64-
- python-version: 3.10.7
65-
tf-version: 2.7.0
6631
steps:
67-
68-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v5
6933

7034
- name: Setup python environment
71-
uses: actions/setup-python@v4
35+
uses: actions/setup-python@v6
7236
with:
7337
python-version: ${{ matrix.python-version }}
7438

7539
- name: Install dependencies
7640
run: |
77-
pip3 install -q tensorflow==${{ matrix.tf-version }}
78-
pip install -q protobuf==3.19.0
79-
pip install -q requests
80-
pip install -e .
41+
python -m pip install -q --upgrade pip setuptools wheel
42+
python -m pip install -q "numpy<2"
43+
python -m pip install -q tensorflow==${{ matrix.tf-version }}
44+
python -m pip install -q protobuf==3.19.0
45+
python -m pip install -q pytest pytest-cov
46+
python -m pip install -e .
47+
python -m pip check
48+
8149
- name: Test with pytest
82-
timeout-minutes: 180
50+
timeout-minutes: 240
8351
run: |
84-
pip install -q pytest
85-
pip install -q pytest-cov
86-
pip install -q python-coveralls
87-
pytest --cov=deepctr --cov-report=xml
52+
pytest --cov=deepctr --cov-report=xml --cov-report=term-missing:skip-covered
53+
8854
- name: Upload coverage to Codecov
89-
uses: codecov/codecov-action@v3.1.0
55+
uses: codecov/codecov-action@v6
9056
with:
91-
token: ${{secrets.CODECOV_TOKEN}}
92-
file: ./coverage.xml
57+
token: ${{ secrets.CODECOV_TOKEN }}
58+
files: ./coverage.xml
9359
flags: pytest
9460
name: py${{ matrix.python-version }}-tf${{ matrix.tf-version }}

.github/workflows/ci2.yml

Lines changed: 56 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,80 @@
1-
name: CI_TF1
1+
name: CI_TF2
22

33
on:
44
push:
5-
path:
6-
- 'deepctr/*'
7-
- 'tests/*'
5+
paths:
6+
- 'deepctr/**'
7+
- 'tests/**'
8+
- 'setup.py'
9+
- 'setup.cfg'
10+
- '.github/workflows/**'
811
pull_request:
9-
path:
10-
- 'deepctr/*'
11-
- 'tests/*'
12+
paths:
13+
- 'deepctr/**'
14+
- 'tests/**'
15+
- 'setup.py'
16+
- 'setup.cfg'
17+
- '.github/workflows/**'
18+
workflow_dispatch:
1219

1320
jobs:
1421
build:
15-
16-
runs-on: ubuntu-latest
17-
timeout-minutes: 360
22+
runs-on: ubuntu-22.04
23+
timeout-minutes: 180
1824
strategy:
25+
fail-fast: false
1926
matrix:
20-
python-version: [ 3.6,3.7 ]
21-
tf-version: [ 1.15.0 ]
27+
include:
28+
- python-version: "3.10"
29+
tf-version: "2.10.0"
30+
use-legacy-keras: "0"
31+
- python-version: "3.10"
32+
tf-version: "2.15.0"
33+
use-legacy-keras: "0"
34+
- python-version: "3.11"
35+
tf-version: "2.15.0"
36+
use-legacy-keras: "0"
37+
- python-version: "3.10"
38+
tf-version: "2.20.0"
39+
use-legacy-keras: "1"
40+
- python-version: "3.11"
41+
tf-version: "2.20.0"
42+
use-legacy-keras: "1"
43+
- python-version: "3.12"
44+
tf-version: "2.20.0"
45+
use-legacy-keras: "1"
46+
env:
47+
TF_USE_LEGACY_KERAS: ${{ matrix.use-legacy-keras }}
2248

23-
exclude:
24-
- python-version: 3.7
25-
tf-version: 1.4.0
26-
- python-version: 3.7
27-
tf-version: 1.12.0
28-
- python-version: 3.7
29-
tf-version: 1.15.0
30-
- python-version: 3.8
31-
tf-version: 1.4.0
32-
- python-version: 3.8
33-
tf-version: 1.14.0
34-
- python-version: 3.8
35-
tf-version: 1.15.0
36-
- python-version: 3.6
37-
tf-version: 2.7.0
38-
- python-version: 3.6
39-
tf-version: 2.8.0
40-
- python-version: 3.6
41-
tf-version: 2.9.0
42-
- python-version: 3.6
43-
tf-version: 2.10.0
44-
- python-version: 3.9
45-
tf-version: 1.4.0
46-
- python-version: 3.9
47-
tf-version: 1.15.0
48-
- python-version: 3.9
49-
tf-version: 2.2.0
50-
- python-version: 3.9
51-
tf-version: 2.5.0
52-
- python-version: 3.9
53-
tf-version: 2.6.0
54-
- python-version: 3.9
55-
tf-version: 2.7.0
56-
- python-version: 3.10.7
57-
tf-version: 1.4.0
58-
- python-version: 3.10.7
59-
tf-version: 1.15.0
60-
- python-version: 3.10.7
61-
tf-version: 2.2.0
62-
- python-version: 3.10.7
63-
tf-version: 2.5.0
64-
- python-version: 3.10.7
65-
tf-version: 2.6.0
66-
- python-version: 3.10.7
67-
tf-version: 2.7.0
6849
steps:
69-
70-
- uses: actions/checkout@v3
50+
- uses: actions/checkout@v5
7151

7252
- name: Setup python environment
73-
uses: actions/setup-python@v4
53+
uses: actions/setup-python@v6
7454
with:
7555
python-version: ${{ matrix.python-version }}
7656

7757
- name: Install dependencies
7858
run: |
79-
pip3 install -q tensorflow==${{ matrix.tf-version }}
80-
pip install -q protobuf==3.19.0
81-
pip install -q requests
82-
pip install -e .
59+
python -m pip install -q --upgrade pip setuptools wheel
60+
python -m pip install -q "numpy<2"
61+
python -m pip install -q tensorflow==${{ matrix.tf-version }}
62+
if [ "${{ matrix.use-legacy-keras }}" = "1" ]; then
63+
python -m pip install -q tf-keras==${{ matrix.tf-version }}
64+
fi
65+
python -m pip install -q pytest pytest-cov
66+
python -m pip install -e .
67+
python -m pip check
68+
8369
- name: Test with pytest
84-
timeout-minutes: 360
70+
timeout-minutes: 180
8571
run: |
86-
pip install -q pytest
87-
pip install -q pytest-cov
88-
pip install -q python-coveralls
89-
pytest --cov=deepctr --cov-report=xml
72+
pytest --cov=deepctr --cov-report=xml --cov-report=term-missing:skip-covered
73+
9074
- name: Upload coverage to Codecov
91-
uses: codecov/codecov-action@v3.1.0
75+
uses: codecov/codecov-action@v6
9276
with:
93-
token: ${{secrets.CODECOV_TOKEN}}
94-
file: ./coverage.xml
77+
token: ${{ secrets.CODECOV_TOKEN }}
78+
files: ./coverage.xml
9579
flags: pytest
9680
name: py${{ matrix.python-version }}-tf${{ matrix.tf-version }}

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DeepCTR
22

33
[![Python Versions](https://img.shields.io/pypi/pyversions/deepctr.svg)](https://pypi.org/project/deepctr)
4-
[![TensorFlow Versions](https://img.shields.io/badge/TensorFlow-1.4+/2.0+-blue.svg)](https://pypi.org/project/deepctr)
4+
[![TensorFlow Versions](https://img.shields.io/badge/TensorFlow-1.15/2.0+-blue.svg)](https://pypi.org/project/deepctr)
55
[![Downloads](https://pepy.tech/badge/deepctr)](https://pepy.tech/project/deepctr)
66
[![PyPI Version](https://img.shields.io/pypi/v/deepctr.svg)](https://pypi.org/project/deepctr)
77
[![GitHub Issues](https://img.shields.io/github/issues/shenweichen/deepctr.svg
@@ -10,7 +10,8 @@
1010

1111

1212
[![Documentation Status](https://readthedocs.org/projects/deepctr-doc/badge/?version=latest)](https://deepctr-doc.readthedocs.io/)
13-
![CI status](https://github.com/shenweichen/deepctr/workflows/CI/badge.svg)
13+
[![CI_TF1](https://github.com/shenweichen/DeepCTR/actions/workflows/ci.yml/badge.svg)](https://github.com/shenweichen/DeepCTR/actions/workflows/ci.yml)
14+
[![CI_TF2](https://github.com/shenweichen/DeepCTR/actions/workflows/ci2.yml/badge.svg)](https://github.com/shenweichen/DeepCTR/actions/workflows/ci2.yml)
1415
[![codecov](https://codecov.io/gh/shenweichen/DeepCTR/branch/master/graph/badge.svg)](https://codecov.io/gh/shenweichen/DeepCTR)
1516
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d4099734dc0e4bab91d332ead8c0bdd0)](https://www.codacy.com/gh/shenweichen/DeepCTR?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=shenweichen/DeepCTR&amp;utm_campaign=Badge_Grade)
1617
[![Disscussion](https://img.shields.io/badge/chat-wechat-brightgreen?style=flat)](./README.md#DisscussionGroup)
@@ -91,9 +92,9 @@ If you find this code useful in your research, please cite it using the followin
9192
- [Github Discussions](https://github.com/shenweichen/DeepCTR/discussions)
9293
- Wechat Discussions
9394

94-
|公众号:浅梦学习笔记|微信:deepctrbot|学习小组 [加入](https://t.zsxq.com/026UJEuzv) [主题集合](https://mp.weixin.qq.com/mp/appmsgalbum?__biz=MjM5MzY4NzE3MA==&action=getalbum&album_id=1361647041096843265&scene=126#wechat_redirect)|
95-
|:--:|:--:|:--:|
96-
| [![公众号](./docs/pics/code.png)](https://github.com/shenweichen/AlgoNotes)| [![微信](./docs/pics/deepctrbot.png)](https://github.com/shenweichen/AlgoNotes)|[![学习小组](./docs/pics/planet_github.png)](https://t.zsxq.com/026UJEuzv)|
95+
|公众号:浅梦学习笔记|微信:deepctrbot|
96+
|:--:|:--:|
97+
| [![公众号](./docs/pics/code.png)](https://github.com/shenweichen/AlgoNotes)| [![微信](./docs/pics/deepctrbot.png)](https://github.com/shenweichen/AlgoNotes)|
9798

9899
## Main contributors([welcome to join us!](./CONTRIBUTING.md))
99100

deepctr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .utils import check_version
22

3-
__version__ = '0.9.3'
3+
__version__ = '0.9.4'
44
check_version(__version__)

deepctr/estimator/models/fibinet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
import tensorflow as tf
11-
from tensorflow.python.keras.layers import Dense, Flatten
11+
from tensorflow.keras.layers import Dense, Flatten
1212

1313
from ..feature_column import get_linear_logit, input_from_feature_columns
1414
from ..utils import deepctr_model_fn, DNN_SCOPE_NAME, variable_scope

deepctr/estimator/models/wdl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
import tensorflow as tf
11-
from tensorflow.python.keras.layers import Dense
11+
from tensorflow.keras.layers import Dense
1212

1313
from ..feature_column import get_linear_logit, input_from_feature_columns
1414
from ..utils import deepctr_model_fn, DNN_SCOPE_NAME, variable_scope

deepctr/feature_column.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from copy import copy
44
from itertools import chain
55

6-
from tensorflow.python.keras.initializers import RandomNormal, Zeros
7-
from tensorflow.python.keras.layers import Input, Lambda
6+
from tensorflow.keras.initializers import RandomNormal, Zeros
7+
from tensorflow.keras.layers import Input, Lambda
88

99
from .inputs import create_embedding_matrix, embedding_lookup, get_dense_input, varlen_embedding_lookup, \
1010
get_varlen_pooling_list, mergeDict

deepctr/inputs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from collections import defaultdict
1010
from itertools import chain
1111

12-
from tensorflow.python.keras.layers import Embedding, Lambda
13-
from tensorflow.python.keras.regularizers import l2
12+
from tensorflow.keras.layers import Embedding, Lambda
13+
from tensorflow.keras.regularizers import l2
1414

1515
from .layers.sequence import SequencePoolingLayer, WeightedSequenceLayer
1616
from .layers.utils import Hash

deepctr/layers/activation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from tensorflow.python.ops.init_ops import Zeros
1313
except ImportError:
1414
from tensorflow.python.ops.init_ops_v2 import Zeros
15-
from tensorflow.python.keras.layers import Layer, Activation
15+
from tensorflow.keras.layers import Layer, Activation
1616

1717
try:
18-
from tensorflow.python.keras.layers import BatchNormalization
18+
from tensorflow.keras.layers import BatchNormalization
1919
except ImportError:
2020
BatchNormalization = tf.keras.layers.BatchNormalization
2121

deepctr/layers/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
"""
88

99
import tensorflow as tf
10-
from tensorflow.python.keras import backend as K
10+
from tensorflow.keras import backend as K
1111

1212
try:
1313
from tensorflow.python.ops.init_ops_v2 import Zeros, Ones, glorot_normal
1414
except ImportError:
1515
from tensorflow.python.ops.init_ops import Zeros, Ones, glorot_normal_initializer as glorot_normal
1616

17-
from tensorflow.python.keras.layers import Layer, Dropout
17+
from tensorflow.keras.layers import Layer, Dropout
1818

1919
try:
20-
from tensorflow.python.keras.layers import BatchNormalization
20+
from tensorflow.keras.layers import BatchNormalization
2121
except ImportError:
2222
BatchNormalization = tf.keras.layers.BatchNormalization
23-
from tensorflow.python.keras.regularizers import l2
23+
from tensorflow.keras.regularizers import l2
2424

2525
from .activation import activation_layer
2626

0 commit comments

Comments
 (0)