@@ -113,24 +113,14 @@ def _validate_bundle_state(self):
113113 outputs_in_validation_set = False
114114 if "training" in self ._bundle_resources :
115115 outputs_in_training_set = self ._dataset_contains_output (label = "training" )
116-
117116 if "validation" in self ._bundle_resources :
118117 outputs_in_validation_set = self ._dataset_contains_output (
119118 label = "validation"
120119 )
121120
122121 if "model" in self ._bundle_resources :
123122 model_type = self .model_config .get ("modelType" )
124- if (
125- not outputs_in_training_set or not outputs_in_validation_set
126- ) and model_type != "baseline" :
127- self .failed_validations .append (
128- "To push a model to the platform, you must provide "
129- "training and a validation sets with predictions. "
130- "The predictions can be specified in the column `predictionsColumnName` "
131- "as integers and/or in the column `predictionScoresColumnName` as "
132- "lists of class probabilities."
133- )
123+
134124 if model_type == "baseline" :
135125 if (
136126 "training" not in self ._bundle_resources
@@ -146,19 +136,81 @@ def _validate_bundle_state(self):
146136 "training and validation sets without predictions in the columns "
147137 "`predictionsColumnName` or `predictionScoresColumnName`."
148138 )
139+ else :
140+ if (
141+ "training" not in self ._bundle_resources
142+ and "validation" not in self ._bundle_resources
143+ ):
144+ self .failed_validations .append (
145+ "You are trying to push a model to the platform, but "
146+ "you did not provide a training or validation set. "
147+ "To push a model to the platform, you must provide "
148+ "either: \n "
149+ "- training and validation sets; or \n "
150+ "- a validation set. \n "
151+ "In any case, ensure that the predictions are provided in the "
152+ "datasets."
153+ )
154+ elif ("training" not in self ._bundle_resources ) and (
155+ "validation" in self ._bundle_resources
156+ ):
157+ if not outputs_in_validation_set :
158+ self .failed_validations .append (
159+ "You are trying to push a model and a validation set to the platform. "
160+ "However, the validation set does not contain predictions. "
161+ "Please provide predictions for the validation set. "
162+ )
163+ elif (
164+ "training" in self ._bundle_resources
165+ and "validation" not in self ._bundle_resources
166+ ):
167+ self .failed_validations .append (
168+ "You are trying to push a model and a training set to the platform. "
169+ "To push a model to the platform, you must provide "
170+ "either: \n "
171+ "- training and validation sets; or \n "
172+ "- a validation set. \n "
173+ "In any case, ensure that the predictions are provided in the "
174+ "datasets."
175+ )
176+ elif ("training" in self ._bundle_resources ) and (
177+ "validation" in self ._bundle_resources
178+ ):
179+ if not outputs_in_training_set or not outputs_in_validation_set :
180+ self .failed_validations .append (
181+ "You are trying to push a model, a training set and a validation "
182+ "set to the platform. "
183+ "However, the training or the validation set do not contain predictions. "
184+ "Please provide predictions for both the training and the validation sets."
185+ )
186+
149187 else :
150- if "training" in self ._bundle_resources and outputs_in_validation_set :
151- self .failed_validations .append (
152- "A training set was provided alongside with a validation set with"
153- " predictions. Please either provide only a validation set with"
154- " predictions, or a model and both datasets with predictions."
155- )
156- elif outputs_in_training_set :
157- self .failed_validations .append (
158- "The training dataset contains predictions, but no model was"
159- " provided. To push a training set with predictions, please provide"
160- " a model and a validation set with predictions as well."
161- )
188+ if (
189+ "training" in self ._bundle_resources
190+ and "validation" not in self ._bundle_resources
191+ ):
192+ if outputs_in_training_set :
193+ self .failed_validations .append (
194+ "The training dataset contains predictions, but no model was"
195+ " provided. To push a training set with predictions, please provide"
196+ " a model and a validation set with predictions as well."
197+ )
198+ elif (
199+ "training" not in self ._bundle_resources
200+ and "validation" in self ._bundle_resources
201+ ):
202+ # This is allowed -- listed just for completeness
203+ pass
204+ elif (
205+ "training" in self ._bundle_resources
206+ and "validation" in self ._bundle_resources
207+ ):
208+ if outputs_in_training_set or outputs_in_validation_set :
209+ self .failed_validations .append (
210+ "You are trying to push a training set and a validation set to the platform. "
211+ "However, the training or the validation set contain predictions. "
212+ "To push datasets with predictions, please provide a model as well."
213+ )
162214
163215 def _validate_bundle_resources (self ):
164216 """Runs the corresponding validations for each resource in the bundle."""
0 commit comments