@@ -30,6 +30,7 @@ import (
3030 "github.com/cortexlabs/cortex/pkg/operator/schema"
3131 "github.com/cortexlabs/cortex/pkg/types"
3232 "github.com/cortexlabs/cortex/pkg/types/spec"
33+ "github.com/cortexlabs/cortex/pkg/types/userconfig"
3334)
3435
3536func Deploy (env cliconfig.Environment , configPath string , projectFileList []string , deployDisallowPrompt bool ) ([]schema.DeployResult , error ) {
@@ -45,11 +46,26 @@ func Deploy(env cliconfig.Environment, configPath string, projectFileList []stri
4546 return nil , err
4647 }
4748
48- projectFiles , err := newProjectFiles (projectFileList , configPath )
49+ if ! files .IsAbsOrTildePrefixed (configPath ) {
50+ return nil , errors .ErrorUnexpected (fmt .Sprintf ("%s is not an absolute path" , configPath ))
51+ }
52+ projectRoot := files .Dir (configPath )
53+
54+ projectFiles , err := newProjectFiles (projectFileList , projectRoot )
55+ if err != nil {
56+ return nil , err
57+ }
58+
59+ apiConfigs , err := spec .ExtractAPIConfigs (configBytes , types .LocalProviderType , configFileName , nil , nil )
4960 if err != nil {
5061 return nil , err
5162 }
5263
64+ return deploy (env , apiConfigs , projectFiles , deployDisallowPrompt )
65+ }
66+
67+ func deploy (env cliconfig.Environment , apiConfigs []userconfig.API , projectFiles ProjectFiles , deployDisallowPrompt bool ) ([]schema.DeployResult , error ) {
68+ var err error
5369 var awsClient * aws.Client
5470 var gcpClient * gcp.Client
5571
@@ -72,27 +88,23 @@ func Deploy(env cliconfig.Environment, configPath string, projectFileList []stri
7288 }
7389 }
7490
75- apiConfigs , err := spec .ExtractAPIConfigs (configBytes , types .LocalProviderType , configFileName , nil , nil )
76- if err != nil {
77- return nil , err
78- }
79-
8091 models := []spec.CuratedModelResource {}
8192 err = ValidateLocalAPIs (apiConfigs , & models , projectFiles , awsClient , gcpClient )
8293 if err != nil {
8394 err = errors .Append (err , fmt .Sprintf ("\n \n api configuration schema for Realtime API can be found at https://docs.cortex.dev/v/%s/deployments/realtime-api/api-configuration" , consts .CortexVersionMinor ))
8495 return nil , err
8596 }
8697
87- projectID , err := files .HashFile (projectFileList [0 ], projectFileList [1 :]... )
98+ projectRelFilePaths := projectFiles .AllAbsPaths ()
99+ projectID , err := files .HashFile (projectRelFilePaths [0 ], projectRelFilePaths [1 :]... )
88100 if err != nil {
89- return nil , errors .Wrap (err , "failed to hash directory" , filepath . Dir ( configPath ) )
101+ return nil , errors .Wrap (err , "failed to hash directory" , projectFiles . projectRoot )
90102 }
91103
92104 results := make ([]schema.DeployResult , len (apiConfigs ))
93105 for i := range apiConfigs {
94106 apiConfig := apiConfigs [i ]
95- api , msg , err := UpdateAPI (& apiConfig , models , configPath , projectID , deployDisallowPrompt , awsClient )
107+ api , msg , err := UpdateAPI (& apiConfig , models , projectFiles . projectRoot , projectID , deployDisallowPrompt , awsClient )
96108 results [i ].Message = msg
97109 if err != nil {
98110 results [i ].Error = errors .Message (err )
0 commit comments