Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
292 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
java/src/main/java/com/bentoml | ||
kotlin/src/main/kotlin/com/bentoml | ||
js/bentoml | ||
go/bentoml | ||
swift/Sources/bentoml | ||
grpc-client/java/src/main/java/com/bentoml | ||
grpc-client/kotlin/src/main/kotlin/com/bentoml | ||
grpc-client/js/bentoml | ||
grpc-client/go/bentoml | ||
grpc-client/swift/Sources/bentoml | ||
**/*/node_modules | ||
thirdparty | ||
grpc-client/thirdparty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Bentoml\Grpc\V1alpha1\BentoServiceClient; | ||
use Bentoml\Grpc\V1alpha1\NDArray; | ||
use Bentoml\Grpc\V1alpha1\Request; | ||
|
||
require dirname(__FILE__) . '/vendor/autoload.php'; | ||
|
||
function call() | ||
{ | ||
$hostname = 'localhost:3000'; | ||
$apiName = "classify"; | ||
$to_parsed = array("3.5", "2.4", "7.8", "5.1"); | ||
$data = array_map("floatval", $to_parsed); | ||
$shape = array(1, 4); | ||
$client = new BentoServiceClient($hostname, [ | ||
'credentials' => Grpc\ChannelCredentials::createInsecure(), | ||
]); | ||
$request = new Request(); | ||
$request->setApiName($apiName); | ||
$payload = new NDArray(); | ||
$payload->setShape($shape); | ||
$payload->setFloatValues($data); | ||
$payload->setDtype(\Bentoml\Grpc\V1alpha1\NDArray\DType::DTYPE_FLOAT); | ||
|
||
list($response, $status) = $client->Call($request)->wait(); | ||
if ($status->code !== Grpc\STATUS_OK) { | ||
echo "ERROR: " . $status->code . ", " . $status->details . PHP_EOL; | ||
exit(1); | ||
} | ||
echo $response->getMessage() . PHP_EOL; | ||
} | ||
|
||
call(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if ! $(which php >/dev/null); then | ||
echo "PHP is required." | ||
exit 0 | ||
fi | ||
|
||
if ! $(which composer >/dev/null); then | ||
echo "composer is required." | ||
exit 0 | ||
fi | ||
|
||
[[ -f ./composer.lock ]] && composer update || composer install | ||
|
||
echo "Running PHP client" | ||
|
||
php -d extension=grpc -d max_execution_time=300 BentoServiceClient.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
pushd .. >/dev/null | ||
|
||
! [[ -d "thirdparty" ]] && mkdir thirdparty | ||
|
||
pushd thirdparty >/dev/null | ||
! [[ -d "protobuf" ]] && git clone -b v3.19.4 https://github.com/protocolbuffers/protobuf.git | ||
popd | ||
pushd .. >/dev/null | ||
# We will use BentoML tools/bazel.rc | ||
echo "Building shared C++ gRPC..." | ||
bazel build @com_github_grpc_grpc//:all | ||
bazel build @com_google_protobuf//:protoc | ||
if ! [ -f "bazel-bin/src/compiler/grpc_php_plugin" ]; then | ||
echo "We will compile grpc_php_plugin from source." | ||
bazel build @com_github_grpc_grpc//src/compiler:grpc_php_plugin | ||
fi | ||
|
||
PROTOC=$(pwd)/bazel-bin/external/com_google_protobuf/protoc | ||
PLUGIN=protoc-gen-grpc=$(pwd)/bazel-bin/src/compiler/grpc_php_plugin | ||
popd | ||
|
||
"$PROTOC" -I . -I ./thirdparty/protobuf/src --php_out=php --grpc_out=php --plugin="$PLUGIN" bentoml/grpc/v1alpha1/service.proto | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "bentoml/grpc-php-client", | ||
"description": "BentoML gRPC client for PHP", | ||
"require": { | ||
"grpc/grpc": "1.42.0", | ||
"google/protobuf": "3.19.4" | ||
}, | ||
"license": "Apache-2.0", | ||
"autoload": { | ||
"psr-4": { | ||
"GBPMetadata\\": "GPBMetadata/", | ||
"Bentoml\\": "Bentoml" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "BentoML Team" | ||
} | ||
] | ||
} |
Oops, something went wrong.