Skip to content

Commit

Permalink
Fix Python version
Browse files Browse the repository at this point in the history
It wasn't being passed through the stack correctly. Also added
some sanity tests for the Python -> Go -> Python round trip.

Signed-off-by: Ben Firshman <[email protected]>
  • Loading branch information
bfirsh authored and andreasjansson committed Jan 14, 2021
1 parent 81953e3 commit 6c041b2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions go/pkg/cli/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ func writeExperimentCommon(au aurora.Aurora, w *tabwriter.Writer, exp *project.E
fmt.Fprintf(w, "%s\t\n", au.Faint("(none)"))
}

fmt.Fprintf(w, "\t\n")
fmt.Fprintf(w, "%s\t\n", au.Bold("System"))
fmt.Fprintf(w, "Python version:\t%s\n", exp.PythonVersion)
if exp.PythonVersion != "" {
fmt.Fprintf(w, "\t\n")
fmt.Fprintf(w, "%s\t\n", au.Bold("System"))
fmt.Fprintf(w, "Python version:\t%s\n", exp.PythonVersion)
}

fmt.Fprintf(w, "\t\n")
fmt.Fprintf(w, "%s\t\n", au.Bold("Python Packages"))
Expand Down
2 changes: 2 additions & 0 deletions go/pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ type CreateExperimentArgs struct {
Command string
Params map[string]param.Value
PythonPackages map[string]string
PythonVersion string
}

func (p *Project) CreateExperiment(args CreateExperimentArgs, async bool, workChan chan func() error, quiet bool) (*Experiment, error) {
Expand Down Expand Up @@ -233,6 +234,7 @@ func (p *Project) CreateExperiment(args CreateExperimentArgs, async bool, workCh
Config: conf,
Command: args.Command,
Path: args.Path,
PythonVersion: args.PythonVersion,
PythonPackages: args.PythonPackages,
ReplicateVersion: global.Version,
}
Expand Down
1 change: 1 addition & 0 deletions go/pkg/shared/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (s *server) CreateExperiment(ctx context.Context, req *servicepb.CreateExpe
Command: pbReqExp.GetCommand(),
Params: valueMapFromPb(pbReqExp.GetParams()),
PythonPackages: pbReqExp.GetPythonPackages(),
PythonVersion: pbReqExp.GetPythonVersion(),
}
proj, err := s.getProject()
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions python/tests/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ def test_init_and_checkpoint(temp_workdir):
metadata = json.load(fh)
assert metadata["id"] == experiment.id
assert metadata["params"] == {"learning_rate": 0.002}
assert metadata["host"] == ""
assert metadata["user"] != ""
# FIXME: this is broken https://github.com/replicate/replicate/issues/492
assert metadata["config"]["repository"].startswith("file://")
assert metadata["command"] != ""
assert metadata["path"] == "."
assert metadata["python_version"] != ""
assert len(metadata["python_packages"]) > 0
assert metadata["replicate_version"] != ""

with tempfile.TemporaryDirectory() as tmpdir:
with tarfile.open(experiment_tar_path) as tar:
Expand Down

0 comments on commit 6c041b2

Please sign in to comment.