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

Cleanup useless gen_config.sh. #603

Merged
merged 9 commits into from
Feb 8, 2018
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ matrix:
- cd go && glide install && go get k8s.io/kubernetes || echo 1
- bash ./vendor/k8s.io/code-generator/generate-groups.sh "deepcopy,client,informer,lister" github.com/PaddlePaddle/cloud/go/pkg/client github.com/PaddlePaddle/cloud/go/pkg/apis paddlepaddle:v1alpha1
- grep "github.com/paddlepaddle/cloud" -nR pkg/client | awk -F ':' '{print $1}' | xargs sed -i 's|github.com/paddlepaddle/cloud|github.com/PaddlePaddle/cloud|g'
- bash .tools/gen_config.sh && glide install --strip-vendor && go test $(glide novendor)
- glide install --strip-vendor && go test $(glide novendor)
- language: python
python: 2.7
sudo: required
Expand Down
10 changes: 0 additions & 10 deletions go/.tools/gen_config.sh

This file was deleted.

4 changes: 0 additions & 4 deletions go/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
FROM ubuntu:16.04

ADD .tools /pfsserver/.tools
RUN bash /pfsserver/.tools/gen_config.sh

ADD ./cmd/pfsserver/pfsserver /pfsserver/
RUN mkdir /pfsserver/log
4 changes: 4 additions & 0 deletions go/cmd/paddlecloud/paddlecloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import (

pfsmod "github.com/PaddlePaddle/cloud/go/filemanager/pfsmodules"
"github.com/PaddlePaddle/cloud/go/paddlecloud"
"github.com/PaddlePaddle/cloud/go/utils/config"
"github.com/google/subcommands"
)

func main() {
pfsmod.Config = config.ParseDefaultConfig()
paddlecloud.Config = pfsmod.Config

subcommands.Register(subcommands.HelpCommand(), "")
subcommands.Register(subcommands.CommandsCommand(), "")
subcommands.Register(&paddlecloud.SubmitCmd{}, "")
Expand Down
6 changes: 6 additions & 0 deletions go/cmd/paddlectl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import (
"flag"
"os"

pfsmod "github.com/PaddlePaddle/cloud/go/filemanager/pfsmodules"
"github.com/PaddlePaddle/cloud/go/paddlecloud"
"github.com/PaddlePaddle/cloud/go/paddlectl"
"github.com/PaddlePaddle/cloud/go/utils/config"
"github.com/google/subcommands"
)

func main() {
pfsmod.Config = config.ParseDefaultConfig()
paddlecloud.Config = pfsmod.Config

subcommands.Register(subcommands.HelpCommand(), "")
subcommands.Register(subcommands.CommandsCommand(), "")
subcommands.Register(&paddlectl.SubmitCmd{}, "")
Expand Down
2 changes: 1 addition & 1 deletion go/filemanager/pfsmodules/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// Config is global config object for pfs commandline
var Config = config.ParseDefaultConfig()
var Config *config.SubmitConfig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Config global is defined in upload.go, should it be placed in a common file?

Copy link
Collaborator Author

@gongweibao gongweibao Feb 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In different packages, they all have Config variable.


type uploadChunkResponse struct {
Err string `json:"err"`
Expand Down
2 changes: 1 addition & 1 deletion go/paddlecloud/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
)

// Config is global config object for paddlecloud commandline
var Config = config.ParseDefaultConfig()
var Config *config.SubmitConfig

// SubmitCmd define the subcommand of submitting paddle training jobs.
type SubmitCmd struct {
Expand Down
2 changes: 1 addition & 1 deletion go/paddlectl/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
)

// Config is global config object for paddlectl commandline
var Config = config.ParseDefaultConfig()
var Config *config.SubmitConfig

// SubmitCmd define the subcommand of submitting paddle training jobs.
type SubmitCmd struct {
Expand Down
24 changes: 23 additions & 1 deletion go/utils/restclient/token_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package restclient

import (
"errors"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -38,12 +39,33 @@ func fakeServer() (*http.Server, int) {
return srv, listener.Addr().(*net.TCPAddr).Port
}

func mkdir_p(path string) error {
fi, err := os.Stat(path)

if os.IsExist(err) {
if !fi.IsDir() {
return errors.New("exist a same name file")
}

return nil
}

if err := os.MkdirAll(path, 0700); err != nil {
return err
}

return nil
}

func TestTokenParse(t *testing.T) {
srv, port := fakeServer()
defer srv.Shutdown(nil)

// test token fetching
os.Remove(filepath.Join(pathutil.UserHomeDir(), ".paddle", "token_cache"))
path := filepath.Join(pathutil.UserHomeDir(), ".paddle")
require.Nil(t, mkdir_p(path), "mkdir ", path)

os.Remove(filepath.Join(path, "token_cache"))
tmpconf := &config.SubmitConfig{ActiveConfig: &config.SubmitConfigDataCenter{
Name: "test",
Username: "testuser",
Expand Down