Skip to content

Commit 29f3b95

Browse files
committed
resolve conflict
1 parent ef4f6f8 commit 29f3b95

9 files changed

+354
-5
lines changed

samples/model-builder/conftest.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ def mock_import_text_dataset(mock_text_dataset):
130130
yield mock
131131

132132

133-
"""
134-
----------------------------------------------------------------------------
135-
TrainingJob Fixtures
136-
----------------------------------------------------------------------------
137-
"""
133+
@pytest.fixture
134+
def mock_import_video_data(mock_video_dataset):
135+
with patch.object(mock_video_dataset, "import_data") as mock:
136+
yield mock
137+
138+
139+
# ----------------------------------------------------------------------------
140+
# TrainingJob Fixtures
141+
# ----------------------------------------------------------------------------
138142

139143

140144
@pytest.fixture
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import List, Union
16+
17+
from google.cloud import aiplatform
18+
19+
20+
# [START aiplatform_sdk_create_and_import_dataset_video_sample]
21+
def create_and_import_dataset_video_sample(
22+
project: str,
23+
location: str,
24+
display_name: str,
25+
src_uris: Union[str, List[str]],
26+
sync: bool = True,
27+
):
28+
aiplatform.init(project=project, location=location)
29+
30+
ds = aiplatform.VideoDataset.create(
31+
display_name=display_name,
32+
gcs_source=src_uris,
33+
import_schema_uri=aiplatform.schema.dataset.ioformat.video.classification,
34+
sync=sync,
35+
)
36+
37+
ds.wait()
38+
39+
print(ds.display_name)
40+
print(ds.resource_name)
41+
return ds
42+
43+
44+
# [END aiplatform_sdk_create_and_import_dataset_video_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
import test_constants as constants
17+
import create_and_import_dataset_video_sample
18+
19+
from google.cloud.aiplatform import schema
20+
21+
22+
def test_create_and_import_dataset_video_sample(
23+
mock_sdk_init, mock_create_video_dataset
24+
):
25+
26+
create_and_import_dataset_video_sample.create_and_import_dataset_video_sample(
27+
project=constants.PROJECT,
28+
location=constants.LOCATION,
29+
src_uris=constants.GCS_SOURCES,
30+
display_name=constants.DISPLAY_NAME,
31+
)
32+
33+
mock_sdk_init.assert_called_once_with(
34+
project=constants.PROJECT, location=constants.LOCATION
35+
)
36+
mock_create_video_dataset.assert_called_once_with(
37+
display_name=constants.DISPLAY_NAME,
38+
gcs_source=constants.GCS_SOURCES,
39+
import_schema_uri=schema.dataset.ioformat.video.classification,
40+
sync=True,
41+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import List, Union
16+
17+
from google.cloud import aiplatform
18+
19+
20+
# [START aiplatform_sdk_import_data_video_action_recognition_sample]
21+
def import_data_video_action_recognition_sample(
22+
project: str,
23+
location: str,
24+
dataset_name: str,
25+
src_uris: Union[str, List[str]],
26+
sync: bool = True,
27+
):
28+
aiplatform.init(project=project, location=location)
29+
30+
ds = aiplatform.VideoDataset(dataset_name=dataset_name)
31+
32+
ds.import_data(
33+
gcs_source=src_uris,
34+
import_schema_uri=aiplatform.schema.dataset.ioformat.video.action_recognition,
35+
sync=sync,
36+
)
37+
38+
ds.wait()
39+
40+
print(ds.display_name)
41+
print(ds.resource_name)
42+
return ds
43+
44+
45+
# [END aiplatform_sdk_import_data_video_action_recognition_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
import test_constants as constants
17+
import import_data_video_action_recognition_sample
18+
19+
from google.cloud.aiplatform import schema
20+
21+
22+
@pytest.mark.usefixtures("mock_get_video_dataset")
23+
def test_import_data_video_action_recognition_sample(
24+
mock_sdk_init, mock_import_video_data
25+
):
26+
27+
import_data_video_action_recognition_sample.import_data_video_action_recognition_sample(
28+
project=constants.PROJECT,
29+
location=constants.LOCATION,
30+
dataset_name=constants.DATASET_NAME,
31+
src_uris=constants.GCS_SOURCES,
32+
)
33+
34+
mock_sdk_init.assert_called_once_with(
35+
project=constants.PROJECT, location=constants.LOCATION
36+
)
37+
38+
mock_import_video_data.assert_called_once_with(
39+
gcs_source=constants.GCS_SOURCES,
40+
import_schema_uri=schema.dataset.ioformat.video.action_recognition,
41+
sync=True,
42+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import List, Union
16+
17+
from google.cloud import aiplatform
18+
19+
20+
# [START aiplatform_sdk_import_data_video_classification_sample]
21+
def import_data_video_classification_sample(
22+
project: str,
23+
location: str,
24+
dataset_name: str,
25+
src_uris: Union[str, List[str]],
26+
sync: bool = True,
27+
):
28+
aiplatform.init(project=project, location=location)
29+
30+
ds = aiplatform.VideoDataset(dataset_name=dataset_name)
31+
32+
print(ds.display_name)
33+
print(ds.resource_name)
34+
35+
ds.import_data(
36+
gcs_source=src_uris,
37+
import_schema_uri=aiplatform.schema.dataset.ioformat.video.classification,
38+
sync=sync,
39+
)
40+
41+
ds.wait()
42+
43+
return ds
44+
45+
46+
# [END aiplatform_sdk_import_data_video_classification_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
import test_constants as constants
17+
import import_data_video_classification_sample
18+
19+
from google.cloud.aiplatform import schema
20+
21+
22+
@pytest.mark.usefixtures("mock_get_video_dataset")
23+
def test_import_data_video_classification_sample(mock_sdk_init, mock_import_video_data):
24+
25+
import_data_video_classification_sample.import_data_video_classification_sample(
26+
project=constants.PROJECT,
27+
location=constants.LOCATION,
28+
dataset_name=constants.DATASET_NAME,
29+
src_uris=constants.GCS_SOURCES,
30+
)
31+
32+
mock_sdk_init.assert_called_once_with(
33+
project=constants.PROJECT, location=constants.LOCATION
34+
)
35+
36+
mock_import_video_data.assert_called_once_with(
37+
gcs_source=constants.GCS_SOURCES,
38+
import_schema_uri=schema.dataset.ioformat.video.classification,
39+
sync=True,
40+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import List, Union
16+
17+
from google.cloud import aiplatform
18+
19+
20+
# [START aiplatform_sdk_import_data_video_object_tracking_sample]
21+
def import_data_video_object_tracking_sample(
22+
project: str,
23+
location: str,
24+
dataset_name: str,
25+
src_uris: Union[str, List[str]],
26+
sync: bool = True,
27+
):
28+
aiplatform.init(project=project, location=location)
29+
30+
ds = aiplatform.VideoDataset(dataset_name=dataset_name)
31+
32+
ds.import_data(
33+
gcs_source=src_uris,
34+
import_schema_uri=aiplatform.schema.dataset.ioformat.video.object_tracking,
35+
sync=sync,
36+
)
37+
38+
ds.wait()
39+
40+
print(ds.display_name)
41+
print(ds.resource_name)
42+
return ds
43+
44+
45+
# [END aiplatform_sdk_import_data_video_object_tracking_sample]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
import test_constants as constants
17+
import import_data_video_object_tracking_sample
18+
19+
from google.cloud.aiplatform import schema
20+
21+
22+
@pytest.mark.usefixtures("mock_get_video_dataset")
23+
def test_import_data_video_object_tracking_sample(
24+
mock_sdk_init, mock_import_video_data
25+
):
26+
27+
import_data_video_object_tracking_sample.import_data_video_object_tracking_sample(
28+
project=constants.PROJECT,
29+
location=constants.LOCATION,
30+
dataset_name=constants.DATASET_NAME,
31+
src_uris=constants.GCS_SOURCES,
32+
)
33+
34+
mock_sdk_init.assert_called_once_with(
35+
project=constants.PROJECT, location=constants.LOCATION
36+
)
37+
38+
mock_import_video_data.assert_called_once_with(
39+
gcs_source=constants.GCS_SOURCES,
40+
import_schema_uri=schema.dataset.ioformat.video.object_tracking,
41+
sync=True,
42+
)

0 commit comments

Comments
 (0)