diff --git a/src/server/oasisapi/analyses/models.py b/src/server/oasisapi/analyses/models.py index 8c3e7aaae..3d1408ea6 100644 --- a/src/server/oasisapi/analyses/models.py +++ b/src/server/oasisapi/analyses/models.py @@ -529,16 +529,12 @@ def generate_and_run(self, initiator, version): errors['settings_file'] = ['Must not be null'] if not self.portfolio.location_file: errors['portfolio'] = ['"location_file" must not be null'] - - # get loc lines (replace with func?) - try: - loc_lines = self.portfolio.location_file_len() - except Exception as e: - raise ValidationError(f"Failed to read location file size for chunking: {e}") - if not isinstance(loc_lines, int): - errors['portfolio'] = [ - f'Failed to read "location_file" size, content_type={self.portfolio.location_file.content_type} might not be supported'] else: + # get loc lines + try: + loc_lines = self.portfolio.location_file_len() + except Exception as e: + errors['portfolio'] = [f"Failed to read location file size for chunking: {e}"] if loc_lines < 1: errors['portfolio'] = ['"location_file" must at least one row'] @@ -624,14 +620,10 @@ def generate_inputs(self, initiator, version): try: loc_lines = self.portfolio.location_file_len() except Exception as e: - raise ValidationError(f"Failed to read location file size for chunking: {e}") - if not isinstance(loc_lines, int): - errors['portfolio'] = [ - f'Failed to read "location_file" size, content_type={self.portfolio.location_file.content_type} might not be supported'] - - else: - if loc_lines < 1: - errors['portfolio'] = ['"location_file" must at least one row'] + errors['portfolio'] = [f"Failed to read location file size for chunking: {e}"] + if loc_lines < 1: + errors['portfolio'] = ['"location_file" must at least one row'] + if errors: raise ValidationError(errors) diff --git a/src/server/oasisapi/analyses/v2_api/tests/test_analysis_model.py b/src/server/oasisapi/analyses/v2_api/tests/test_analysis_model.py index 7d66a0fc4..687a936d4 100644 --- a/src/server/oasisapi/analyses/v2_api/tests/test_analysis_model.py +++ b/src/server/oasisapi/analyses/v2_api/tests/test_analysis_model.py @@ -182,10 +182,12 @@ def test_state_is_ready___run_is_started(self, status, task_gen_id, task_run_id) with patch('src.server.oasisapi.analyses.models.Analysis.v2_start_input_and_loss_generation_signature', PropertyMock(return_value=task_sig)): analysis.generate_and_run(initiator, version='v2') + loc_lines = 4 + events = None task_sig.on_error.assert_called_once() task_sig.apply_async.assert_called_with( - args=[analysis.pk, initiator.pk], + args=[analysis.pk, initiator.pk, loc_lines, events], priority=4 )