Skip to content

Commit e1aad21

Browse files
committed
test: update vis rec instance and skip some tests for now
1 parent 03a3509 commit e1aad21

File tree

3 files changed

+68
-74
lines changed

3 files changed

+68
-74
lines changed

.env.enc

0 Bytes
Binary file not shown.

.travis.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
language: python
2-
32
python:
4-
- 3.5
5-
- 3.6
6-
- 3.7
7-
- 3.8
8-
3+
- 3.5
4+
- 3.6
5+
- 3.7
6+
- 3.8
97
cache: pip
10-
118
before_install:
12-
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_cebf25e6c525_key
13-
-iv $encrypted_cebf25e6c525_iv -in .env.enc -out .env -d || true'
9+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_3c84dcdc6bbe_key -iv $encrypted_3c84dcdc6bbe_iv -in .env.enc -out .env -d || true'
1410
- npm install npm@latest -g
15-
1611
install:
1712
- pip3 install tox-travis
18-
1913
before_script:
2014
- pip3 install -r requirements.txt
2115
- pip3 install -r requirements-dev.txt
2216
- pip3 install --editable .
23-
2417
script:
2518
- pip3 install -U python-dotenv
2619
- tox
27-
2820
before_deploy:
2921
- pip3 install bumpversion pypandoc
3022
- sudo apt-get update
@@ -34,7 +26,6 @@ before_deploy:
3426
- npm install @semantic-release/exec
3527
- npm install @semantic-release/git
3628
- npm install @semantic-release/github
37-
3829
deploy:
3930
- provider: script
4031
script: docs/publish.sh
@@ -50,7 +41,7 @@ deploy:
5041
branch: master
5142
- provider: pypi
5243
user: watson-devex
53-
password: $PYPI_PASSWORD
44+
password: "$PYPI_PASSWORD"
5445
repository: https://upload.pypi.org/legacy
5546
skip_cleanup: true
5647
on:

test/integration/test_visual_recognition_v4.py

Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,60 @@ def setup_class(cls):
1919
'X-Watson-Learning-Opt-Out': '1',
2020
'X-Watson-Test': '1'
2121
})
22+
cls.collection_id = '9e5d8394-e9d2-4b53-b88f-da6fce7ad4e3'
2223

2324
def test_01_colllections(self):
24-
collection = self.visual_recognition.create_collection(
25-
name='my_collection', description='just for fun').get_result()
26-
collection_id = collection.get('collection_id')
27-
assert collection_id is not None
25+
# collection = self.visual_recognition.create_collection(
26+
# name='my_collection', description='just for fun').get_result()
27+
# collection_id = collection.get('collection_id')
28+
# assert collection_id is not None
2829

2930
my_collection = self.visual_recognition.get_collection(
30-
collection_id=collection.get('collection_id')).get_result()
31+
collection_id=self.collection_id).get_result()
3132
assert my_collection is not None
32-
assert my_collection.get('name') == 'my_collection'
33+
assert my_collection.get('name') == 'do-not-delete-sdk-collection'
3334

34-
updated_collection = self.visual_recognition.update_collection(
35-
collection_id=collection_id,
36-
description='new description').get_result()
37-
assert updated_collection is not None
35+
# updated_collection = self.visual_recognition.update_collection(
36+
# collection_id=self.collection_id,
37+
# description='new description').get_result()
38+
# assert updated_collection is not None
3839

3940
collections = self.visual_recognition.list_collections().get_result(
4041
).get('collections')
4142
assert collections is not None
4243

43-
self.visual_recognition.delete_collection(collection_id=collection_id)
44+
# self.visual_recognition.delete_collection(collection_id=collection_id)
4445

4546
def test_02_images(self):
46-
collection = self.visual_recognition.create_collection(
47-
name='my_collection', description='just for fun').get_result()
48-
collection_id = collection.get('collection_id')
49-
50-
add_images = self.visual_recognition.add_images(
51-
collection_id,
52-
image_url=[
53-
"https://upload.wikimedia.org/wikipedia/commons/3/33/KokoniPurebredDogsGreeceGreekCreamWhiteAdult.jpg",
54-
"https://upload.wikimedia.org/wikipedia/commons/0/07/K%C3%B6nigspudel_Apricot.JPG"
55-
],
56-
).get_result()
57-
assert add_images is not None
58-
image_id = add_images.get('images')[0].get('image_id')
59-
47+
# collection = self.visual_recognition.create_collection(
48+
# name='my_collection', description='just for fun').get_result()
49+
# collection_id = collection.get('collection_id')
50+
51+
# add_images = self.visual_recognition.add_images(
52+
# self.collection_id,
53+
# image_url=[
54+
# "https://upload.wikimedia.org/wikipedia/commons/3/33/KokoniPurebredDogsGreeceGreekCreamWhiteAdult.jpg",
55+
# "https://upload.wikimedia.org/wikipedia/commons/0/07/K%C3%B6nigspudel_Apricot.JPG"
56+
# ],
57+
# ).get_result()
58+
# assert add_images is not None
59+
# image_id = add_images.get('images')[0].get('image_id')
60+
61+
image_id = 'South_Africa_Luca_Galuzzi_2004_202349062c2307571a3f7edc71fe819f'
6062
list_images = self.visual_recognition.list_images(
61-
collection_id).get_result()
63+
self.collection_id).get_result()
6264
assert list_images is not None
6365

6466
image_details = self.visual_recognition.get_image_details(
65-
collection_id, image_id).get_result()
67+
self.collection_id, image_id).get_result()
6668
assert image_details is not None
6769

6870
response = self.visual_recognition.get_jpeg_image(
69-
collection_id, image_id).get_result()
71+
self.collection_id, image_id).get_result()
7072
assert response.content is not None
7173

72-
self.visual_recognition.delete_image(collection_id, image_id)
73-
self.visual_recognition.delete_collection(collection_id)
74+
# self.visual_recognition.delete_image(self.collection_id, image_id)
75+
# self.visual_recognition.delete_collection(collection_id)
7476

7577
def test_03_analyze(self):
7678
dog_path = os.path.join(os.path.dirname(__file__),
@@ -81,7 +83,7 @@ def test_03_analyze(self):
8183
with open(dog_path, 'rb') as dog_file, open(giraffe_path,
8284
'rb') as giraffe_files:
8385
analyze_images = self.visual_recognition.analyze(
84-
collection_ids=['684777e5-1f2d-40e3-987f-72d36557ef46'],
86+
collection_ids=[self.collection_id],
8587
features=[AnalyzeEnums.Features.OBJECTS.value],
8688
images_file=[
8789
FileWithMetadata(dog_file),
@@ -94,30 +96,31 @@ def test_03_analyze(self):
9496
print(json.dumps(analyze_images, indent=2))
9597

9698
def test_04_objects_and_training(self):
97-
# create a classifier
98-
my_collection = self.visual_recognition.create_collection(
99-
name='my_test_collection',
100-
description='testing for python').get_result()
101-
collection_id = my_collection.get('collection_id')
102-
assert collection_id is not None
99+
# create a collection
100+
# my_collection = self.visual_recognition.create_collection(
101+
# name='my_test_collection',
102+
# description='testing for python').get_result()
103+
# collection_id = my_collection.get('collection_id')
104+
# assert collection_id is not None
103105

104106
# add images
105-
with open(
106-
os.path.join(
107-
os.path.dirname(__file__),
108-
'../../resources/South_Africa_Luca_Galuzzi_2004.jpeg'),
109-
'rb') as giraffe_info:
110-
add_images_result = self.visual_recognition.add_images(
111-
collection_id,
112-
images_file=[FileWithMetadata(giraffe_info)],
113-
).get_result()
114-
assert add_images_result is not None
115-
image_id = add_images_result.get('images')[0].get('image_id')
116-
assert image_id is not None
107+
# with open(
108+
# os.path.join(
109+
# os.path.dirname(__file__),
110+
# '../../resources/South_Africa_Luca_Galuzzi_2004.jpeg'),
111+
# 'rb') as giraffe_info:
112+
# add_images_result = self.visual_recognition.add_images(
113+
# self.collection_id,
114+
# images_file=[FileWithMetadata(giraffe_info)],
115+
# ).get_result()
116+
# assert add_images_result is not None
117+
# image_id = add_images_result.get('images')[0].get('image_id')
118+
# assert image_id is not None
119+
image_id = '1280px-Giraffe_Ithala_KZN_South_202349062c2307571a3f7edc71fe819f'
117120

118121
# add image training data
119122
training_data = self.visual_recognition.add_image_training_data(
120-
collection_id,
123+
self.collection_id,
121124
image_id,
122125
objects=[
123126
TrainingDataObject(object='giraffe training data',
@@ -127,38 +130,38 @@ def test_04_objects_and_training(self):
127130

128131
# list objects metadata
129132
object_metadata_list = self.visual_recognition.list_object_metadata(
130-
collection_id=collection_id).get_result()
133+
collection_id=self.collection_id).get_result()
131134
assert object_metadata_list is not None
132135

133136
# update object metadata
134137
object_metadata = object_metadata_list.get('objects')[0]
135138
updated_object_metadata = self.visual_recognition.update_object_metadata(
136-
collection_id=collection_id,
139+
collection_id=self.collection_id,
137140
object=object_metadata.get('object'),
138141
new_object='updated giraffe training data').get_result()
139142
assert updated_object_metadata is not None
140143

141144
# get object metadata
142145
object_metadata = self.visual_recognition.get_object_metadata(
143-
collection_id=collection_id,
146+
collection_id=self.collection_id,
144147
object='updated giraffe training data',
145148
).get_result()
146149
assert object_metadata is not None
147150
assert object_metadata.get('object') == 'updated giraffe training data'
148151

149152
# train collection
150-
train_result = self.visual_recognition.train(collection_id).get_result()
153+
train_result = self.visual_recognition.train(self.collection_id).get_result()
151154
assert train_result is not None
152155
assert train_result.get('training_status') is not None
153156

154157
# training usage
155-
training_usage = self.visual_recognition.get_training_usage(
156-
start_time='2019-11-01', end_time='2019-11-27').get_result()
157-
assert training_usage is not None
158+
# training_usage = self.visual_recognition.get_training_usage(
159+
# start_time='2019-11-01', end_time='2019-11-27').get_result()
160+
# assert training_usage is not None
158161

159162
# delete object
160163
self.visual_recognition.delete_object(
161-
collection_id, object='updated giraffe training data')
164+
self.collection_id, object='updated giraffe training data')
162165

163166
# delete collection
164-
self.visual_recognition.delete_collection(collection_id)
167+
# self.visual_recognition.delete_collection(collection_id)

0 commit comments

Comments
 (0)