Skip to content

Commit 680c0fc

Browse files
saetaFrank Chen
authored and
Frank Chen
committed
Merge internal changes into public repository (change 240667526) (#318)
1 parent 12e6e95 commit 680c0fc

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ Shell.
1111

1212
_Note:_ This repository is a public mirror, pull requests will not be accepted.
1313
Please file an issue if you have a feature or bug request.
14+
15+
## Running Models
16+
17+
To run models in the `models` subdirectory, you may need to add the top-level
18+
`/models` folder to the Python path with the command:
19+
20+
```
21+
export PYTHONPATH="$PYTHONPATH:/path/to/models"
22+
```

tools/ctpu/config/config_gcloud.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ import (
2727
"github.com/zieckey/goini"
2828
)
2929

30-
// TODO(saeta): Add a GCE compatible environment.
31-
3230
const appDefaultFile = "application_default_credentials.json"
3331

3432
func gcloudConfig() (*Config, error) {
3533
homedir := ""
34+
if configDir, ok := os.LookupEnv("CLOUDSDK_CONFIG"); ok {
35+
return buildGcloudEnvConfig(configDir, true)
36+
}
3637
user, err := user.Current()
3738
if err != nil {
3839
// Fallback to looking up in the environment as a final attempt.

tools/ctpu/config/config_gcloud_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package config
1717

1818
import (
19+
"os"
1920
"path"
2021
"strings"
2122
"testing"
@@ -46,6 +47,39 @@ func TestGcloudClean(t *testing.T) {
4647
}
4748
}
4849

50+
func TestGcloudEnvConfigOverride(t *testing.T) {
51+
cfgDir := testGcloudConfigDir("clean")
52+
originalEnv, originalEnvOk := os.LookupEnv("CLOUDSDK_CONFIG")
53+
defer func() {
54+
// Attempt to set the original env back.
55+
if originalEnvOk {
56+
os.Setenv("CLOUDSDK_CONFIG", originalEnv)
57+
}
58+
}()
59+
60+
if err := os.Setenv("CLOUDSDK_CONFIG", cfgDir); err != nil {
61+
t.Fatalf("Could not set the env: %#v", err)
62+
}
63+
cfg, err := gcloudConfig()
64+
65+
if err != nil {
66+
t.Fatalf("Error creating config: %v", err)
67+
}
68+
69+
if cfg.ActiveConfiguration != "ctpu9" {
70+
t.Error("Active configuration: " + cfg.ActiveConfiguration)
71+
}
72+
if cfg.account != "[email protected]" {
73+
t.Error("Account: " + cfg.account)
74+
}
75+
if cfg.Project != "ctpu9-test-project" {
76+
t.Error("Project: " + cfg.Project)
77+
}
78+
if cfg.Zone != "us-central1-c" {
79+
t.Error("Zone: " + cfg.Zone)
80+
}
81+
}
82+
4983
func TestGcloudCorruptedMissingConfig(t *testing.T) {
5084
cfgDir := testGcloudConfigDir("corrupted")
5185
_, err := buildGcloudEnvConfig(cfgDir, true)

0 commit comments

Comments
 (0)