Skip to content

Commit

Permalink
Update python code styles based on what's provided in .style.yapf (ku…
Browse files Browse the repository at this point in the history
…beflow#2447)

* Fix Python code styles based on Pep8 and flake8

* More syle fixes to Python code

* Update python code styles based on what's provided in .style.yapf

* Sync with master and update styles

* Sync with master

* More Python style fixes

* Changes per code review

* Sync with master and update the remaining files

* Add a .flake8 config file for future reference
  • Loading branch information
ashahba authored and k8s-ci-robot committed Feb 20, 2019
1 parent 39060f2 commit 667d618
Show file tree
Hide file tree
Showing 85 changed files with 3,534 additions and 3,180 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = E111, E114
exclude = .git
max-complexity = 10
5 changes: 3 additions & 2 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[style]
based_on_style = google
indent_width: 2
continuation_indent_width: 2
indent_width = 2
continuation_indent_width = 4
spaces_before_comment = 2
2 changes: 1 addition & 1 deletion bootstrap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test-known-platforms-generate: test-known-platforms-init
# By default we disable loading plugins and link dockerfordesktop into the kfctl binary (static)
static:
@ex pkg/apis/apps/group.go <hack/static
@ex cmd/kfctl/cmd/root.go <hack/static || echo Plugin functionality disabled
@ex cmd/kfctl/cmd/root.go <hack/static || echo Plugin functionality disabled

plugins:
@ex pkg/apis/apps/group.go <hack/plugins
Expand Down
16 changes: 8 additions & 8 deletions bootstrap/cmd/kfctl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ type KfApp interface {

kfctl includes platforms that implement the KfApp interface. (gcp will be added in the next phase)

- platform: **ksonnet**
- platform: **ksonnet**
- bootstrap/pkg/client/ksonnet/ksonnet.go
- platform: **minikube**
- platform: **minikube**
- bootstrap/pkg/client/minikube/minikube.go
- platform: **docker-for-desktop**
- bootstrap/pkg/client/dockerfordesktop/dockerfordesktop.go
Expand Down Expand Up @@ -217,30 +217,30 @@ make test-known-platforms-generate

## Debugging

In order to debug in goland, the plugin code must be disabled.
See https://github.com/golang/go/issues/23733.
In order to debug in goland, the plugin code must be disabled.
See https://github.com/golang/go/issues/23733.
This is expected to be resolved with golang 1.12.X
To disable the plugin code (which will cause dockerfordesktop.go to be linked statically in kfctl)
To disable the plugin code (which will cause dockerfordesktop.go to be linked statically in kfctl)
and allow debugging in goland run:

```
make static
```

otherwise run
otherwise run

```
make plugins
```

Note: the default is `make static`. Do not checkin code after doing `make plugins`.

Note: static and plugins make targets result in 2 files being changed:
Note: static and plugins make targets result in 2 files being changed:
- pkg/apis/apps/group.go
- cmd/kfctl/cmd/root.go

These files have comments that are toggled (effectively a golang macro hack).
This will go away when the fix noted above is available and we've moved to
This will go away when the fix noted above is available and we've moved to
this version of go.


Expand Down
69 changes: 36 additions & 33 deletions bootstrap/hack/send_ks_request.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#!/usr/bin/python
"""A script for manual testing and experimenting with the ks server.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A script for manual testing and experimenting with the ks server.
TODO(jlewi): Should we use this as the basis for doing
E2E integration testing? We can run the server in a subprocess.
Send requests to it and then run various checks on the results.
TODO(jlewi): Should we use this as the basis for doing E2E integration testing?
We can run the server in a subprocess. Send requests to it and then run various
checks on the results.
"""
import argparse
import datetime
import logging
import requests


def main():
parser = argparse.ArgumentParser(
description="Script to test sending requests to the ksonnet server.")
description="Script to test sending requests to the ksonnet server.")

parser.add_argument(
"--endpoint",
default="http://localhost:8080",
type=str,
help="The endpoint of the server")
"--endpoint",
default="http://localhost:8080",
type=str,
help="The endpoint of the server")

args = parser.parse_args()

Expand All @@ -28,34 +30,35 @@ def main():
now = datetime.datetime.now()

data = {
"Name": "test-app-" + now.strftime("%Y%m%d-%H%M%S"),
"AppConfig": {
"Registries": [
{
"Name": "kubeflow",
"RegUri": "/home/jlewi/git_kubeflow/kubeflow",
},
],
"Packages": [
{
"Name": "core",
"Registry": "kubeflow",
}
],
},
"Namespace": "kubeflow",
"AutoConfigure": False,
"Name": "test-app-" + now.strftime("%Y%m%d-%H%M%S"),
"AppConfig": {
"Registries": [
{
"Name": "kubeflow",
"RegUri": "/home/jlewi/git_kubeflow/kubeflow",
},
],
"Packages": [{
"Name": "core",
"Registry": "kubeflow",
}],
},
"Namespace": "kubeflow",
"AutoConfigure": False,
}
r = requests.post(create_endpoint, json=data)
if r.status_code != requests.codes.OK:
logging.error("Request failed: status_code: %s", r.status_code)

logging.info("Result Body: %s", r.content)


if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format=('%(levelname)s|%(asctime)s'
'|%(pathname)s|%(lineno)d| %(message)s'),
datefmt='%Y-%m-%dT%H:%M:%S',
)
logging.basicConfig(
level=logging.INFO,
format=('%(levelname)s|%(asctime)s'
'|%(pathname)s|%(lineno)d| %(message)s'),
datefmt='%Y-%m-%dT%H:%M:%S',
)
logging.getLogger().setLevel(logging.INFO)
main()
Loading

0 comments on commit 667d618

Please sign in to comment.