Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: promote Vision to v2 #7904

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions Core/src/ServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Trace\TraceClient;
use Google\Cloud\Translate\V2\TranslateClient;
use Google\Cloud\Vision\VisionClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;
use Google\Cloud\Vision\VisionClient as DeprecatedVisionClient;
use Psr\Cache\CacheItemPoolInterface;

/**
Expand Down Expand Up @@ -336,23 +337,19 @@ public function trace(array $config = [])
}

/**
* Google Cloud Vision allows you to understand the content of an image,
* classify images into categories, detect text, objects, faces and more.
* Find more information at the
* [Google Cloud Vision docs](https://cloud.google.com/vision/docs/).
*
* Example:
* ```
* $vision = $cloud->vision();
* ```
*
* @param array $config [optional] Configuration options. See
* {@see \Google\Cloud\Core\ServiceBuilder::__construct()} for the available options.
* @return VisionClient
* @deprecated
* @see ImageAnnotatorClient
* @throws \BadMethodCallException
*/
public function vision(array $config = [])
{
return $this->createClient(VisionClient::class, 'vision', $config);
if (class_exists(DeprecatedVisionClient::class)) {
return $this->createClient(DeprecatedVisionClient::class, 'vision', $config);
}
throw new \BadMethodCallException(sprintf(
'This method is no longer supported, create %s directly instead.',
ImageAnnotatorClient::class
));
}

/**
Expand Down
2 changes: 0 additions & 2 deletions Core/tests/Snippet/ServiceBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Trace\TraceClient;
use Google\Cloud\Translate\TranslateClient;
use Google\Cloud\Vision\VisionClient;

/**
* @group root
Expand Down Expand Up @@ -63,7 +62,6 @@ public function serviceBuilderMethods()
['speech', SpeechClient::class, 'speech'],
['storage', StorageClient::class, 'storage'],
['trace', TraceClient::class, 'trace'],
['vision', VisionClient::class, 'vision'],
['translate', TranslateClient::class, 'translate']
];
}
Expand Down
4 changes: 0 additions & 4 deletions Core/tests/Unit/ServiceBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Core\Tests\Unit\Fixtures;
use Google\Cloud\Translate\TranslateClient;
use Google\Cloud\Vision\VisionClient;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;
Expand Down Expand Up @@ -190,9 +189,6 @@ public function serviceProvider()
], [
'translate',
TranslateClient::class
], [
'vision',
VisionClient::class
]
];
}
Expand Down
2 changes: 0 additions & 2 deletions Core/tests/Unit/ServicesNotFoundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ private static function getApis()
"Trace",
"Translate",
"VideoIntelligence",
"Vision",
];
}

Expand All @@ -92,7 +91,6 @@ public function serviceBuilderMethods()
['speech'],
['storage'],
['trace'],
['vision'],
['translate']
];
}
Expand Down
4 changes: 2 additions & 2 deletions Vision/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
deep-copy-regex:
- source: /google/cloud/vision/v1/.*-php/(.*)
dest: /owl-bot-staging/Vision/V1/$1
- source: /google/cloud/vision/(v1)/.*-php/(.*)
dest: /owl-bot-staging/Vision/$1/$2
api-name: Vision
73 changes: 18 additions & 55 deletions Vision/owlbot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,9 @@

import logging
from pathlib import Path
import synthtool as s
import subprocess

import synthtool as s
from synthtool.languages import php
from synthtool import _tracked_paths

Expand All @@ -29,65 +30,27 @@
# Added so that we can pass copy_excludes in the owlbot_main() call
_tracked_paths.add(src)

# Exclude partial veneer files.
php.owlbot_main(
src=src,
dest=dest,
copy_excludes=[
src / "*/src/V1/ProductSearchClient.php",
src / "*/src/V1/ImageAnnotatorClient.php",
]
)

# Change the wording for the deprecation warning.
s.replace(
'src/*/*_*.php',
r'will be removed in the next major release',
'will be removed in a future release')

### [START] protect vision backwards compatibility

# format generated clients
subprocess.run([
'git',
'apply',
'.owlbot/safesearchannotation.patch'])

### [START] protoc backwards compatibility fixes

# roll back to private properties.
s.replace(
"src/**/V*/**/*.php",
r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$",
r"""Generated from protobuf field \1
*/
private $""")

# Replace "Unwrapped" with "Value" for method names.
s.replace(
"src/**/V*/**/*.php",
r"public function ([s|g]\w{3,})Unwrapped",
r"public function \1Value"
)

### [END] protoc backwards compatibility fixes
php.owlbot_main(src=src, dest=dest)

# fix relative cloud.google.com links
# remove class_alias code
s.replace(
"src/**/V*/**/*.php",
r"(.{0,})\]\((/.{0,})\)",
r"\1](https://cloud.google.com\2)"
)
"src/V*/**/*.php",
r"^// Adding a class alias for backwards compatibility with the previous class name.$"
+ "\n"
+ r"^class_alias\(.*\);$"
+ "\n",
'')

# format generated clients
subprocess.run([
'npx',
'-y',
'-p',
'@prettier/plugin-php@^0.16',
'npm',
'exec',
'--yes',
'--package=@prettier/plugin-php@^0.16',
'--',
'prettier',
'**/Gapic/*',
'**/Client/*',
'--write',
'--parser=php',
'--single-quote',
'--print-width=80'])
'--print-width=120'])
16 changes: 0 additions & 16 deletions Vision/phpunit-snippets.xml.dist

This file was deleted.

Loading
Loading