Skip to content

Conversation

@mosoriob
Copy link
Contributor

Summary

This PR enhances the MINT Ensemble Manager's subtask creation functionality by adding comprehensive validation for variables and regions through GraphQL queries.

Changes Made

🔍 New GraphQL Query Infrastructure

  • Added checkVariableExistsById function in graphql_functions_v2.ts to validate variable existence by ID
  • Added checkRegionExistsById function in graphql_functions_v2.ts to validate region existence by ID
  • Created GraphQL query files:
    • src/classes/graphql/queries/variable/check-by-id.graphql
    • src/classes/graphql/queries/region/check-by-id.graphql

✅ Enhanced Subtask Validation

  • Updated createSubtask function in subTasksService.ts to validate:
    • Driving variables: Ensures all driving variables in the subtask exist in the database
    • Response variables: Ensures all response variables in the subtask exist in the database
    • Region: Validates that the specified region exists
  • Returns clear error messages when validation fails (e.g., "Driving variable 'model__simulation_start_time' does not exist")

🔧 New Service Methods

  • Added checkVariableExistsByName() method to SubTasksService interface
  • Added checkRegionExistsById() method to SubTasksService interface
  • Both methods provide reusable validation functionality for other parts of the application

Benefits

  1. Data Integrity: Prevents creation of subtasks with invalid variable or region references
  2. Better Error Handling: Provides specific error messages when validation fails
  3. Defensive Programming: Validates inputs before database operations
  4. Reusable Components: New validation functions can be used throughout the application

Testing

The validation functions can be tested with specific values like:

  • Driving variable: "model__simulation_start_time"
  • Response variable: "soil_profile_bottom_water__drainage_volume_flux"
  • Region: "ethiopia"

Breaking Changes

None - this is a backward-compatible enhancement that adds validation without changing existing API contracts.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

mosoriob added 8 commits July 11, 2025 20:54
- Enhanced error logging during execution submission to provide clearer feedback on failures.
- Updated method signatures for better readability and consistency in the response structure.
- Removed unnecessary whitespace to improve code cleanliness.
…ation

- Introduced a new endpoint to retrieve the complete model configuration blueprint for subtasks, detailing available parameters and data inputs.
- Updated the README to include a comprehensive programmatic workflow guide, outlining steps for creating problem statements, tasks, and subtasks, as well as selecting models and configuring parameters.
- Enhanced API documentation for clarity and consistency in describing the new blueprint functionality.
- Revised the README to improve the programmatic workflow steps, including clearer task and subtask creation instructions.
- Added detailed request body examples for creating problem statements, tasks, and binding data.
- Updated API documentation to reflect changes in endpoint summaries and descriptions, ensuring consistency and clarity in model configuration and data selection processes.
- Introduced a new function to convert W3 IDs to API URLs for model configurations, enhancing integration with the model catalog.
- Revised parameter configurations in the README to reflect updated values and IDs for model inputs.
- Changed resource URLs for weather-soil and crops configuration to point to the correct datasets.
- Enhanced clarity in the example request body for creating problem statements, ensuring accurate representation of the expected input format.
…ences

- Introduced a new ModelParameter schema in the API documentation, detailing its properties and metadata for enhanced clarity.
- Updated references in the API paths and services to utilize the new ModelParameter schema, streamlining parameter handling in the application.
- Improved consistency in the API documentation by replacing inline parameter definitions with schema references.
- Updated the blueprint endpoint documentation to include a new optional query parameter `detailed`, allowing users to request comprehensive model parameter details.
- Clarified the response behavior based on the `detailed` parameter, specifying the difference between basic and full parameter information.
- Added example curl commands demonstrating the use of the `detailed` parameter for retrieving detailed blueprint information.
…s and validation

- Updated the Subtask creation request schema to include new required fields: `driving_variables`, `response_variables`, and `regionid`.
- Implemented validation logic in the SubTasksService to check the existence of driving variables, response variables, and the specified region, throwing appropriate errors if any are invalid.
- Added new GraphQL functions to verify the existence of variables and regions, improving data integrity during subtask creation.
- Reformatted the README to enhance readability, particularly in the sections detailing query parameters and example request bodies.
- Removed unnecessary comments from JSON examples to streamline the documentation.
- Ensured consistent indentation and structure throughout the document for better user experience.
@mosoriob mosoriob merged commit c69b714 into master Jul 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants