Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEP-1047 Running clean commands in new Job #838

Merged
merged 1 commit into from
Oct 19, 2023
Merged

Conversation

sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Oct 18, 2023

Description

Please include a summary of the change and which issue is fixed.

Fixes # (IEP-XXX)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows,Linux and macOS):

Dependent components impacted by this PR:

  • Component 1
  • Component 2

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • Refactor: Enhanced the responsiveness of the ESP-IDF project cleaning and updating process. Commands now run asynchronously in the background, improving the overall user experience.
  • New Feature: Added new command handlers for project cleaning and updating ESP-IDF, providing more control and flexibility to users.
  • Refactor: Improved code modularity and maintainability by encapsulating command execution logic into a separate method.
  • New Feature: Added new messages and job names for project clean, full clean, and python clean commands, improving the clarity of operations for users.

@coderabbitai
Copy link

coderabbitai bot commented Oct 18, 2023

Walkthrough

The changes primarily focus on improving the responsiveness of the application by executing commands asynchronously in separate jobs. This is achieved by replacing the runCommand method with a new method runCommandInNewJob across multiple handlers. Additionally, new string constants have been added for localization purposes.

Changes

File Path Summary
.../ui/handlers/Messages.java Added four new static string variables for command handlers.
.../ui/handlers/ProjectCleanCommandHandler.java Replaced runCommand with runCommandInNewJob for asynchronous execution.
.../ui/handlers/ProjectFullCleanCommandHandler.java Replaced runCommand with runCommandInNewJob for asynchronous execution.
.../ui/handlers/PythonCleanCommandHandler.java Replaced runCommand with runCommandInNewJob for asynchronous execution.
.../ui/handlers/messages.properties Added new strings for project clean and update commands.
.../ui/update/AbstractToolsHandler.java Added runCommandInNewJob method and modified runCommand to use it.
.../ui/update/Messages.java Added a new string constant for localization.
.../ui/update/messages.properties Added a new string constant for localization.

🐇

In the land of code, where the brackets lie,

A rabbit hopped, with a twinkle in its eye.

"Async tasks, oh what a treat,

Making our app fleet and neat.

With new strings for all to see,

Localization, as easy as one, two, three!" 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 0267c08 and 4937fc7.
Files selected for processing (8)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/Messages.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/ProjectCleanCommandHandler.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/ProjectFullCleanCommandHandler.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/PythonCleanCommandHandler.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/messages.properties (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java (4 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/Messages.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/messages.properties (1 hunks)
Files skipped from review due to trivial changes (4)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/Messages.java
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/ProjectCleanCommandHandler.java
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/ProjectFullCleanCommandHandler.java
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/messages.properties
Additional comments (Suppressed): 8
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/messages.properties (1)
  • 9-11: The new messages added for the job names are clear and descriptive. They will help users understand what process is currently running in the background.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/Messages.java (1)
  • 10-16: The addition of AbstractToolsHandler_RunningCommandFormatString is noted. Ensure that this new string is properly initialized in the corresponding messages.properties file and is used correctly in the context of running commands in the AbstractToolsHandler class.
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/PythonCleanCommandHandler.java (2)
  • 48-51: The runCommand method has been replaced with runCommandInNewJob, which is expected to run the command in a separate job. This change should improve the responsiveness of the application by offloading the execution to a background job. However, ensure that the new method runCommandInNewJob handles errors and exceptions properly, and that it logs the output and errors for debugging purposes.

  • 51-51: The runCommandInNewJob method is now being passed a new argument Messages.PythonCleanCommandHandler_RunningPythonCleanJobName. Ensure that this message is properly defined in the Messages class and the corresponding messages.properties file, and that it is correctly displayed in the user interface.

bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/AbstractToolsHandler.java (4)
  • 14-25: The import statements have been updated to include org.eclipse.core.runtime.IProgressMonitor and org.eclipse.core.runtime.jobs.Job. These classes are used for creating and managing background jobs in Eclipse, which aligns with the PR's goal of executing commands asynchronously in separate jobs.

  • 163-169: The environment variable PYTHONUNBUFFERED is set to 1. This forces Python to run in unbuffered mode, which can be useful for real-time output. However, it can also increase the I/O load. Ensure that this change does not negatively impact the performance of the application.

  • 218-221: The runCommand method now returns an IStatus object instead of void. This allows the caller to check the status of the command execution. Ensure that all calls to this method have been updated to handle the returned status.

  • 299-314: A new method runCommandInNewJob has been added. This method creates a new job with the given name, command arguments, project path, and environment map, and schedules it for execution. The command is executed in the run method of the Job class, and the output is redirected to the console. This is a good practice as it improves the responsiveness of the application by offloading the command execution to a separate thread.

Consider adding error handling in the run method. If the runCommand method throws an exception, it should be caught and logged, and an error status should be returned. This will help in diagnosing issues if the command execution fails.

			protected IStatus run(IProgressMonitor monitor)
			{
				console.println(String.format(Messages.AbstractToolsHandler_RunningCommandFormatString,
						String.join(" ", commandArgs))); //$NON-NLS-1$
				try {
					console.println((runCommand(commandArgs, pathToProject, envMap)));
					return Status.OK_STATUS;
				} catch (Exception e) {
					Logger.log(e);
					return new Status(IStatus.ERROR, IDFCorePlugin.PLUGIN_ID, "Error executing command", e);
				}
			}

@AndriiFilippov
Copy link
Collaborator

hi @sigmaaa !

Tested under:
OS - Windows 10 / Linux Ubuntu 20.04
ESP-IDF: v5.1.1

LGTM 👍

there is only problem: some information is not displayed fully:
image

or here during indexer the PATH info absent at all:

image

probably some buffer problem.

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM

@kolipakakondal kolipakakondal added this to the 2.11.1 milestone Oct 19, 2023
@kolipakakondal kolipakakondal merged commit 516a51e into master Oct 19, 2023
7 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1047 branch October 19, 2023 10:50
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.

3 participants