Skip to content

Added the save definitions options to the PICSA Crops dialog#10231

Open
Emmanuel-Afrifa wants to merge 4 commits intoIDEMSInternational:masterfrom
Emmanuel-Afrifa:adding-save-options-picsa-crops
Open

Added the save definitions options to the PICSA Crops dialog#10231
Emmanuel-Afrifa wants to merge 4 commits intoIDEMSInternational:masterfrom
Emmanuel-Afrifa:adding-save-options-picsa-crops

Conversation

@Emmanuel-Afrifa
Copy link
Collaborator

@Emmanuel-Afrifa Emmanuel-Afrifa commented Feb 11, 2026

Fixes Partly #10041
@lilyclements @rdstern @berylwaswa

I've added the save definitions options to the PICSA Crops dialog.

I used the guinea_two_stations dataset from the library to test this PR.

Developer Testing Checklist

  • Runs without errors
  • OK disabled when dialog is incomplete or invalid
  • OK enabled only when required inputs are valid
  • Reset returns dialog to its default/sensible state
  • Invalid inputs are handled cleanly (e.g. negative, too-large, empty, impossible combos)
  • Running twice with different settings behaves consistently (e.g., open → run → close → reopen → change options checked → run again)
  • All AI/bot comments addressed (fixed, intentionally ignored with explanation, or queried)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Emmanuel-Afrifa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the PICSA Crops dialog by integrating functionality to save crop and proportion definitions. It introduces new user interface components for this purpose, alongside the necessary backend logic to generate and execute the corresponding R code. The changes ensure that users can persist their defined crop and proportion settings, improving data management and workflow efficiency within the application.

Highlights

  • New Save Definition Controls: Two new ucrSave controls, ucrSaveDefinitionCrops and ucrSaveDefinitionProportions, have been added to the PICSA Crops dialog to allow users to store crop and proportion definitions.
  • UI Layout Adjustments: The layout and sizing of numerous existing UI elements within the dlgPICSACrops form have been adjusted to accommodate the newly added save definition controls, ensuring proper visual integration.
  • R Code Generation Logic: New RFunction and ROperator instances have been introduced and configured to handle the dynamic generation of R code for saving crop and proportion definitions, including identifying new data frames and extracting relevant information.
  • Control Linking and Validation: The ucrChkDataCrops and ucrChkDataProp controls are now linked to the new save definition controls, and the dialog's TestOkEnabled method has been updated to include validation checks for the completeness of these new controls.
  • Dynamic R Code Management: Helper methods (Save_Definitions_ControlValueChanged, AddDefinitionCodes, AddDataNames) were added to dynamically manage the addition and removal of R code snippets for saving definitions based on user interactions with the checkboxes.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • instat/dlgPICSACrops.Designer.vb
    • Added ucrSaveDefinitionCrops and ucrSaveDefinitionProportions controls.
    • Adjusted locations and sizes of various existing UI controls to fit new elements.
    • Integrated new ucrSave controls into the form's control collection and declared them as Friend WithEvents.
  • instat/dlgPICSACrops.vb
    • Declared and initialized new RFunction and ROperator members for definition saving logic.
    • Configured ucrSaveDefinitionCrops and ucrSaveDefinitionProportions with prefixes, save types, and data frame selectors.
    • Updated ucrChkDataCrops and ucrChkDataProp to link to the new save definition controls.
    • Implemented R code generation for retrieving data frame names, performing set differences, and extracting definitions.
    • Modified SetRCode to include the new save definition controls.
    • Enhanced TestOkEnabled to validate the completeness of the new save definition controls.
    • Extended ControlContentsChanged event handler to monitor the new save definition controls.
    • Introduced Save_Definitions_ControlValueChanged, AddDefinitionCodes, and AddDataNames methods for dynamic R code management.
Activity
  • The author, Emmanuel-Afrifa, implemented the functionality to add save definitions options to the PICSA Crops dialog.
  • The pull request partly addresses issue Adding in "Save Definitions" Option to different Product Dialogs for PICSA #10041.
  • The author performed testing using the guinea_two_stations dataset.
  • A developer testing checklist was included in the pull request description, outlining various test cases.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds options to save definitions in the PICSA Crops dialog. The changes include UI updates in the designer file and new logic in the code-behind to generate the appropriate R code for the new save options. The implementation is mostly sound, but I've identified a critical bug in the R code generation that will cause a syntax error. I've also included a couple of suggestions to improve code clarity and maintainability.

@lilyclements
Copy link
Contributor

@Emmanuel-Afrifa is this ready for review?

@lilyclements
Copy link
Contributor

@Emmanuel-Afrifa this is good, two bits:

  1. Can you remove the [1] here:

So can this

new_df_name <- setdiff(data_book$get_data_names(), existing_dfs)[1]`

instead be

new_df_name <- setdiff(data_book$get_data_names(), existing_dfs)
  1. I changed the R code so that we no longer have get_season_start_definition. This is just get_crop_definition, so our get_crop_definition is run in both instances. CAn you change get_season_start_definition to be get_crop_definition

…s and also removen the index ([1]) after the setdiff function
@Emmanuel-Afrifa
Copy link
Collaborator Author

@lilyclements Please, I've updated the code accordingly.

Copy link
Contributor

@lilyclements lilyclements left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great @Emmanuel-Afrifa! Nice!
@Rockjunior can you review the code?

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