Skip to content

Commit

Permalink
create separate python sdk for v1alpha3 and v1beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
sperlingxx committed Jul 28, 2020
1 parent 6eeab98 commit e68598e
Show file tree
Hide file tree
Showing 283 changed files with 3,277 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hack/gen-python-sdk/gen_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for VERSION in ${KATIB_VERSIONS[@]}; do
TMP_PATH=${TMP_CODEGEN_PATH/KATIB_VERSION/$VERSION}
java -jar ${SWAGGER_CODEGEN_JAR} generate -i ${SWAGGER_FILE} -l python -o ${TMP_PATH} -c ${SWAGGER_CODEGEN_CONF} -v

python ${POST_GEN_PYTHON_HANDLER} ${TMP_PATH} ${SDK_OUTPUT_PATH}
python ${POST_GEN_PYTHON_HANDLER} ${TMP_PATH} ${SDK_OUTPUT_PATH}/${VERSION}
done

rm ${SWAGGER_CODEGEN_JAR}
12 changes: 6 additions & 6 deletions hack/gen-python-sdk/post_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _rewrite_helper(input_file, output_file, rewrite_rules):
f.writelines(lines)


def update_python_sdk(src, dest, version='v1beta1'):
def update_python_sdk(src, dest, versions=('v1alpha3', 'v1beta1')):
# tiny transformers to refine generated codes
rewrite_rules = [
lambda l: l.replace('import katib', 'from kubeflow import katib'),
Expand All @@ -39,8 +39,10 @@ def update_python_sdk(src, dest, version='v1beta1'):
for src_dir, dest_dir in zip(src_dirs, dest_dirs):
# remove previous generated files explicitly, in case of deprecated instances
for file in os.listdir(dest_dir):
if version in file.lower():
os.remove(os.path.join(dest_dir, file))
for v in versions:
if v in file.lower():
os.remove(os.path.join(dest_dir, file))
break
# fill latest generated files
for file in os.listdir(src_dir):
in_file = os.path.join(src_dir, file)
Expand All @@ -51,6 +53,4 @@ def update_python_sdk(src, dest, version='v1beta1'):


if __name__ == '__main__':
update_python_sdk(src=sys.argv[1],
dest=sys.argv[2],
version='v1beta1' if len(sys.argv) < 4 else sys.argv[3])
update_python_sdk(src=sys.argv[1], dest=sys.argv[2])
Binary file added hack/gen-python-sdk/swagger-codegen-cli.jar
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions sdk/python/v1alpha3/kubeflow/katib/constants/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2019 kubeflow.org.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

# Katib K8S constants
EXPERIMENT_GROUP = 'kubeflow.org'
EXPERIMENT_KIND = 'experiment'
EXPERIMENT_PLURAL = 'experiments'
EXPERIMENT_VERSION = os.environ.get('EXPERIMENT_VERSION', 'v1alpha3')
EXPERIMENT_LOGLEVEL = os.environ.get('EXPERIMENT_LOGLEVEL', 'INFO').upper()

TRIAL_KIND = 'trial'
TRIAL_PLURAL = 'trials'
TRIAL_VERSION = os.environ.get('EXPERIMENT_VERSION', 'v1alpha3')

# How long to wait in seconds for requests to the ApiServer
APISERVER_TIMEOUT = 120
55 changes: 55 additions & 0 deletions sdk/python/v1alpha3/kubeflow/katib/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# coding: utf-8

# flake8: noqa
"""
Katib
Swagger description for Katib # noqa: E501
OpenAPI spec version: v1alpha3-0.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

# import models into model package
from kubeflow.katib.models.v1alpha3_algorithm_setting import V1alpha3AlgorithmSetting
from kubeflow.katib.models.v1alpha3_algorithm_spec import V1alpha3AlgorithmSpec
from kubeflow.katib.models.v1alpha3_collector_spec import V1alpha3CollectorSpec
from kubeflow.katib.models.v1alpha3_early_stopping_setting import V1alpha3EarlyStoppingSetting
from kubeflow.katib.models.v1alpha3_early_stopping_spec import V1alpha3EarlyStoppingSpec
from kubeflow.katib.models.v1alpha3_experiment import V1alpha3Experiment
from kubeflow.katib.models.v1alpha3_experiment_condition import V1alpha3ExperimentCondition
from kubeflow.katib.models.v1alpha3_experiment_list import V1alpha3ExperimentList
from kubeflow.katib.models.v1alpha3_experiment_spec import V1alpha3ExperimentSpec
from kubeflow.katib.models.v1alpha3_experiment_status import V1alpha3ExperimentStatus
from kubeflow.katib.models.v1alpha3_feasible_space import V1alpha3FeasibleSpace
from kubeflow.katib.models.v1alpha3_file_system_path import V1alpha3FileSystemPath
from kubeflow.katib.models.v1alpha3_filter_spec import V1alpha3FilterSpec
from kubeflow.katib.models.v1alpha3_go_template import V1alpha3GoTemplate
from kubeflow.katib.models.v1alpha3_graph_config import V1alpha3GraphConfig
from kubeflow.katib.models.v1alpha3_metric import V1alpha3Metric
from kubeflow.katib.models.v1alpha3_metrics_collector_spec import V1alpha3MetricsCollectorSpec
from kubeflow.katib.models.v1alpha3_nas_config import V1alpha3NasConfig
from kubeflow.katib.models.v1alpha3_objective_spec import V1alpha3ObjectiveSpec
from kubeflow.katib.models.v1alpha3_observation import V1alpha3Observation
from kubeflow.katib.models.v1alpha3_operation import V1alpha3Operation
from kubeflow.katib.models.v1alpha3_optimal_trial import V1alpha3OptimalTrial
from kubeflow.katib.models.v1alpha3_parameter_assignment import V1alpha3ParameterAssignment
from kubeflow.katib.models.v1alpha3_parameter_spec import V1alpha3ParameterSpec
from kubeflow.katib.models.v1alpha3_source_spec import V1alpha3SourceSpec
from kubeflow.katib.models.v1alpha3_suggestion import V1alpha3Suggestion
from kubeflow.katib.models.v1alpha3_suggestion_condition import V1alpha3SuggestionCondition
from kubeflow.katib.models.v1alpha3_suggestion_list import V1alpha3SuggestionList
from kubeflow.katib.models.v1alpha3_suggestion_spec import V1alpha3SuggestionSpec
from kubeflow.katib.models.v1alpha3_suggestion_status import V1alpha3SuggestionStatus
from kubeflow.katib.models.v1alpha3_template_spec import V1alpha3TemplateSpec
from kubeflow.katib.models.v1alpha3_trial import V1alpha3Trial
from kubeflow.katib.models.v1alpha3_trial_assignment import V1alpha3TrialAssignment
from kubeflow.katib.models.v1alpha3_trial_condition import V1alpha3TrialCondition
from kubeflow.katib.models.v1alpha3_trial_list import V1alpha3TrialList
from kubeflow.katib.models.v1alpha3_trial_spec import V1alpha3TrialSpec
from kubeflow.katib.models.v1alpha3_trial_status import V1alpha3TrialStatus
from kubeflow.katib.models.v1alpha3_trial_template import V1alpha3TrialTemplate
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions sdk/python/v1alpha3/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2019 kubeflow.org.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import setuptools

with open('requirements.txt') as f:
REQUIRES = f.readlines()

setuptools.setup(
name='kubeflow-katib',
version='0.0.2',
author="Kubeflow Authors",
author_email='premnath.vel@gmail.com',
license="Apache License Version 2.0",
url="https://github.com/kubeflow/katib/sdk/python",
description="Katib Python SDK",
long_description="Katib Python SDK",
packages=setuptools.find_packages(
include=("kubeflow*")),
package_data={},
include_package_data=False,
zip_safe=False,
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
],
install_requires=REQUIRES
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
99 changes: 99 additions & 0 deletions sdk/python/v1beta1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Kubeflow Katib SDK

Python SDK for Kubeflow Katib

## Requirements.

Python 2.7 and 3.4+

## Installation & Usage

### pip install

```sh
pip install kubeflow-katib
```

Then import package:

```python
from kubeflow import katib
```

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)

## Getting Started

Please follow the [samples](examples/bayesianoptimization-katib-sdk.ipynb) to create, update, delete and get hyperparamaters of Katib Experiment.

## Documentation for API Endpoints

Class | Method | Description
------------ | ------------- | -------------
[KatibClient](docs/KatibClient.md) | [create_experiment](docs/KatibClient.md#create_experiment) | Create Katib Experiment|
[KatibClient](docs/KatibClient.md) | [get_experiment](docs/KatibClient.md#get_experiment) | Get or watch the specified Experiment or all Experiment in the namespace |
[KatibClient](docs/KatibClient.md) | [delete_experiment](docs/KatibClient.md#delete_experiment) | Delete specified Experiment |
[KatibClient](docs/KatibClient.md) | [list_experiments](docs/KatibClient.md#list_experiments) | List all Experiments with status |
[KatibClient](docs/KatibClient.md) | [get_experiment_status](docs/KatibClient.md#get_experiment_status) | Get Experiment status|
[KatibClient](docs/KatibClient.md) | [is_experiment_succeeded](docs/KatibClient.md#is_experiment_succeeded) | Check if Experiment status is Succeeded |
[KatibClient](docs/KatibClient.md) | [list_trials](docs/KatibClient.md#list_trials) | List all trials of specified Experiment |
[KatibClient](docs/KatibClient.md) | [get_optimal_hyperparmeters](docs/KatibClient.md#get_optimal_hyperparmeters) | Get currentOptimalTrial with paramaterAssignments of an Experiment|


## Documentation For Models

- [V1alpha3AlgorithmSetting](docs/V1alpha3AlgorithmSetting.md)
- [V1alpha3AlgorithmSpec](docs/V1alpha3AlgorithmSpec.md)
- [V1alpha3CollectorSpec](docs/V1alpha3CollectorSpec.md)
- [V1alpha3EarlyStoppingSetting](docs/V1alpha3EarlyStoppingSetting.md)
- [V1alpha3EarlyStoppingSpec](docs/V1alpha3EarlyStoppingSpec.md)
- [V1alpha3Experiment](docs/V1alpha3Experiment.md)
- [V1alpha3ExperimentCondition](docs/V1alpha3ExperimentCondition.md)
- [V1alpha3ExperimentList](docs/V1alpha3ExperimentList.md)
- [V1alpha3ExperimentSpec](docs/V1alpha3ExperimentSpec.md)
- [V1alpha3ExperimentStatus](docs/V1alpha3ExperimentStatus.md)
- [V1alpha3FeasibleSpace](docs/V1alpha3FeasibleSpace.md)
- [V1alpha3FileSystemPath](docs/V1alpha3FileSystemPath.md)
- [V1alpha3FilterSpec](docs/V1alpha3FilterSpec.md)
- [V1alpha3GoTemplate](docs/V1alpha3GoTemplate.md)
- [V1alpha3GraphConfig](docs/V1alpha3GraphConfig.md)
- [V1alpha3Metric](docs/V1alpha3Metric.md)
- [V1alpha3MetricsCollectorSpec](docs/V1alpha3MetricsCollectorSpec.md)
- [V1alpha3NasConfig](docs/V1alpha3NasConfig.md)
- [V1alpha3ObjectiveSpec](docs/V1alpha3ObjectiveSpec.md)
- [V1alpha3Observation](docs/V1alpha3Observation.md)
- [V1alpha3Operation](docs/V1alpha3Operation.md)
- [V1alpha3OptimalTrial](docs/V1alpha3OptimalTrial.md)
- [V1alpha3ParameterAssignment](docs/V1alpha3ParameterAssignment.md)
- [V1alpha3ParameterSpec](docs/V1alpha3ParameterSpec.md)
- [V1alpha3SourceSpec](docs/V1alpha3SourceSpec.md)
- [V1alpha3Suggestion](docs/V1alpha3Suggestion.md)
- [V1alpha3SuggestionCondition](docs/V1alpha3SuggestionCondition.md)
- [V1alpha3SuggestionList](docs/V1alpha3SuggestionList.md)
- [V1alpha3SuggestionSpec](docs/V1alpha3SuggestionSpec.md)
- [V1alpha3SuggestionStatus](docs/V1alpha3SuggestionStatus.md)
- [V1alpha3TemplateSpec](docs/V1alpha3TemplateSpec.md)
- [V1alpha3Trial](docs/V1alpha3Trial.md)
- [V1alpha3TrialAssignment](docs/V1alpha3TrialAssignment.md)
- [V1alpha3TrialCondition](docs/V1alpha3TrialCondition.md)
- [V1alpha3TrialList](docs/V1alpha3TrialList.md)
- [V1alpha3TrialSpec](docs/V1alpha3TrialSpec.md)
- [V1alpha3TrialStatus](docs/V1alpha3TrialStatus.md)
- [V1alpha3TrialTemplate](docs/V1alpha3TrialTemplate.md)


## Documentation For Authorization

All endpoints do not require authorization.


## Author

prem0912
Loading

0 comments on commit e68598e

Please sign in to comment.