Skip to content

Commit 3f62e3d

Browse files
authored
Deprecate train command with warning before future removal (#2818)
* deprecate train command with warning before future removal * chore: fmt Signed-off-by: Mark Phelps <mphelps@cloudflare.com> --------- Signed-off-by: Mark Phelps <mphelps@cloudflare.com>
1 parent 65da700 commit 3f62e3d

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Test that the train command shows a deprecation warning
2+
3+
# Train command should fail (no cog.yaml) but still show deprecation warning
4+
! cog train
5+
stderr 'Command "train" is deprecated'
6+
stderr 'will be removed in a future version of Cog'
7+
8+
-- predict.py --
9+
from cog import BasePredictor
10+
11+
class Predictor(BasePredictor):
12+
def predict(self, s: str) -> str:
13+
return "hello " + s

pkg/cli/train.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ If 'image' is passed, it will run the training on that Docker image.
3333
It must be an image that has been built by Cog.
3434
3535
Otherwise, it will build the model in the current directory and train it.`,
36-
RunE: cmdTrain,
37-
Args: cobra.MaximumNArgs(1),
38-
Hidden: true,
36+
RunE: cmdTrain,
37+
Args: cobra.MaximumNArgs(1),
38+
Hidden: true,
39+
Deprecated: "the train command will be removed in a future version of Cog",
3940
}
4041

4142
addBuildProgressOutputFlag(cmd)

pkg/cli/train_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cli
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestTrainCommandIsDeprecated(t *testing.T) {
10+
cmd := newTrainCommand()
11+
require.NotEmpty(t, cmd.Deprecated, "train command should have a deprecation message")
12+
require.Contains(t, cmd.Deprecated, "will be removed in a future version")
13+
}

0 commit comments

Comments
 (0)