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

Add doc for API #1406

Merged
merged 7 commits into from
May 31, 2019
Merged
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
9 changes: 9 additions & 0 deletions backend/api/experiment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,19 @@ service ExperimentService {
}

message CreateExperimentRequest {
// The experiment to be created
Experiment experiment = 1;
}

message GetExperimentRequest {
// The ID of the experiment to be retrieved
string id = 1;
}

message ListExperimentsRequest {
string page_token = 1;
int32 page_size = 2;

// Can be format of "field_name", "field_name asc" or "field_name des"
// Ascending by default.
string sort_by = 3;
Expand All @@ -105,12 +108,18 @@ message ListExperimentsRequest {
}

message ListExperimentsResponse {
// A list of experiments returned.
repeated Experiment experiments = 1;

// The total number of experiments for the given query.
int32 total_size = 3;

// The token to list the next page of experiments.
string next_page_token = 2;
}

message DeleteExperimentRequest{
// The ID of the experiment to be deleted.
string id = 1;
}

Expand Down
35 changes: 22 additions & 13 deletions backend/api/generate_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
# directory using Bazel, then copies them back into the source tree so they can
# be checked-in.

set -ex

BAZEL_BINDIR=$(bazel info bazel-bin)
SWAGGER_CMD=../../bazel-bin/external/com_github_go_swagger/cmd/swagger/*stripped/swagger
AUTOGEN_CMD="../../bazel-bin/external/com_github_mbrukman_autogen/autogen_tool"
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
SWAGGER_CMD=${DIR}/../../bazel-bin/external/com_github_go_swagger/cmd/swagger/*stripped/swagger
AUTOGEN_CMD="${DIR}/../../bazel-bin/external/com_github_mbrukman_autogen/autogen_tool"
GENERATED_GO_PROTO_FILES="${BAZEL_BINDIR}/backend/api/api_generated_go_sources/src/github.com/kubeflow/pipelines/backend/api/go_client/*.go"

# TODO this script should be able to be run from anywhere, not just within .../backend/api/
Expand All @@ -39,7 +42,7 @@ bazel build //backend/api:api_generated_go_sources
set -x
# Copy the generated files into the source tree and add license.
for f in $GENERATED_GO_PROTO_FILES; do
target=go_client/$(basename ${f})
target=${DIR}/go_client/$(basename ${f})
cp $f $target
chmod 766 $target
${AUTOGEN_CMD} -i --no-tlc -c "Google LLC" -l apache $target
Expand All @@ -49,41 +52,47 @@ done
bazel build //backend/api:api_swagger
cp ${BAZEL_BINDIR}/backend/api/*.swagger.json swagger

jq -s '
reduce .[] as $item ({}; . * $item) |
.info.title = "KF Pipelines API" |
.info.description = "Generated Kubeflow Pipelines server API"
' ${DIR}/swagger/{run,job,pipeline,experiment,pipeline.upload}.swagger.json > "${DIR}/swagger/kfp_api_single_file.swagger.json"

# Generate Go HTTP client from the swagger files.
${SWAGGER_CMD} generate client \
-f swagger/job.swagger.json \
-f ${DIR}/swagger/job.swagger.json \
-A job \
--principal models.Principal \
-c job_client \
-m job_model \
-t go_http_client

${SWAGGER_CMD} generate client \
-f swagger/run.swagger.json \
-f ${DIR}/swagger/run.swagger.json \
-A run \
--principal models.Principal \
-c run_client \
-m run_model \
-t go_http_client

${SWAGGER_CMD} generate client \
-f swagger/experiment.swagger.json \
-f ${DIR}/swagger/experiment.swagger.json \
-A experiment \
--principal models.Principal \
-c experiment_client \
-m experiment_model \
-t go_http_client

${SWAGGER_CMD} generate client \
-f swagger/pipeline.upload.swagger.json \
-f ${DIR}/swagger/pipeline.upload.swagger.json \
-A pipeline_upload \
--principal models.Principal \
-c pipeline_upload_client \
-m pipeline_upload_model \
-t go_http_client

${SWAGGER_CMD} generate client \
-f swagger/pipeline.swagger.json \
-f ${DIR}/swagger/pipeline.swagger.json \
-A pipeline \
--principal models.Principal \
-c pipeline_client \
Expand All @@ -92,16 +101,16 @@ ${SWAGGER_CMD} generate client \

# Hack to fix an issue with go-swagger
# See https://github.com/go-swagger/go-swagger/issues/1381 for details.
sed -i -- 's/MaxConcurrency int64 `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' ./go_http_client/job_model/api_job.go
sed -i -- 's/IntervalSecond int64 `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' ./go_http_client/job_model/api_periodic_schedule.go
sed -i -- 's/MaxConcurrency string `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' ./go_http_client/job_model/api_job.go
sed -i -- 's/IntervalSecond string `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' ./go_http_client/job_model/api_periodic_schedule.go
sed -i -- 's/MaxConcurrency int64 `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' ${DIR}/go_http_client/job_model/api_job.go
sed -i -- 's/IntervalSecond int64 `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' ${DIR}/go_http_client/job_model/api_periodic_schedule.go
sed -i -- 's/MaxConcurrency string `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' ${DIR}/go_http_client/job_model/api_job.go
sed -i -- 's/IntervalSecond string `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' ${DIR}/go_http_client/job_model/api_periodic_schedule.go

# Executes the //go:generate directives in the generated code.
go generate ./...

# Add license to files in go_http_client.
find go_http_client/ -name "*.go" -exec ${AUTOGEN_CMD} -i --no-tlc -c "Google LLC" -l apache {} \;
find ${DIR}/go_http_client/ -name "*.go" -exec ${AUTOGEN_CMD} -i --no-tlc -c "Google LLC" -l apache {} \;

# Finally, run gazelle to add BUILD files for the generated code.
bazel run //:gazelle

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions backend/api/go_http_client/job_model/api_cron_schedule.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/api/go_http_client/job_model/api_job.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions backend/api/go_http_client/job_model/api_periodic_schedule.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/api/go_http_client/job_model/api_trigger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions backend/api/go_http_client/pipeline_model/api_pipeline.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading