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

Add support for HTML, CSS and Javascript in LocalCommandLineCodeExecutor #2303

Closed
wants to merge 1 commit into from

Conversation

ekzhu
Copy link
Collaborator

@ekzhu ekzhu commented Apr 6, 2024

Why are these changes needed?

Many web application development use cases require support for simply saving the static content like HTML, CSS and Javascript.

This PR adds support for those languages in LocalCommandLineCodeExecutor.

It also add option in LocalCommandLineCodeExecutor for only saving the code files not executing them. This is useful when the web application code starts a server and never exits.

Related issue number

Closes #2379 #2383

Checks

@codecov-commenter
Copy link

codecov-commenter commented Apr 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.02%. Comparing base (4a44093) to head (cffea7a).

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2303       +/-   ##
===========================================
+ Coverage   38.14%   67.02%   +28.88%     
===========================================
  Files          78       78               
  Lines        7865     7879       +14     
  Branches     1683     1824      +141     
===========================================
+ Hits         3000     5281     +2281     
+ Misses       4615     2118     -2497     
- Partials      250      480      +230     
Flag Coverage Δ
unittest 14.20% <8.00%> (?)
unittests 66.03% <100.00%> (+27.90%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ekzhu ekzhu requested a review from jackgerrits April 6, 2024 01:29
@sonichi sonichi enabled auto-merge April 6, 2024 02:24
@sonichi
Copy link
Contributor

sonichi commented Apr 6, 2024

who requested this feature? Could you add them as reviewers?

else:
try:
program = _cmd(lang)
except NotImplementedError:
Copy link
Member

Choose a reason for hiding this comment

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

This is confusing - some languages silently get saved and ignored and some don't? Ignoring NotImplementedError doesn't feel right

save_code_only feels way too coarse to me. I would rather see a mapping of language to whether it should be executed or just saved.

Copy link
Collaborator Author

@ekzhu ekzhu Apr 10, 2024

Choose a reason for hiding this comment

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

Agreed. A mapping to specify whether a given language should be executed is more suitable here. In that case we can allow user to specify the executing program as well, bringing more transparency and getting rid of _cmd.

@ekzhu
Copy link
Collaborator Author

ekzhu commented Apr 10, 2024

who requested this feature? Could you add them as reviewers?

I am working on an example that creates a web application using AutoGen GroupChat. Supporting HTML, Javascript and CSS in code executor is required to address this scenario, as we don't want to execute those code blocks.

Add several contributors that has been working on software engineering related usage cases.

@ekzhu ekzhu marked this pull request as draft April 10, 2024 05:48
auto-merge was automatically disabled April 10, 2024 05:48

Pull request was converted to draft

@ekzhu
Copy link
Collaborator Author

ekzhu commented Apr 10, 2024

Converted to draft as this needs more work. Will be back on this next week.

@Grigorij-Dudnik
Copy link
Collaborator

@ekzhu You know, I'm just using tool for that ;) For me chenges are looking good, we will don't need to define tool for file saving any more. Maybe we should extend that feature for other file formats, for example .vue?

@asandez1
Copy link
Contributor

This PR is for LocalCommandLineCodeExecutor and util.py , can we translate the support for docker_commandline_code_executor ?

program = sys.executable
else:
try:
program = _cmd(lang)
Copy link

Choose a reason for hiding this comment

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

there can implement like this:

  1. put this using function _cmd to instance method, so user can overwrite it
  2. _cmd can return None,means there is no need to execute
program = self.get_lang_cmd(lang)
if program is None:
    logs_all += f"Code saved to {str(written_file)}\n"
    exitcode = 0
    continue

@ekzhu
Copy link
Collaborator Author

ekzhu commented Apr 17, 2024

@asandez1 @zjjott

I am swamped currently. Would you like to continue the work in this PR to address your issue #2379?

You can take a look at the @jackgerrits 's comment earlier #2303 (comment) regarding how to parameterize the executor for how to execute specific languages.

You can fork from this branch to create your own PR. Then I can close this one.

@asandez1
Copy link
Contributor

@asandez1 @zjjott

I am swamped currently. Would you like to continue the work in this PR to address your issue #2379?

You can take a look at the @jackgerrits 's comment earlier #2303 (comment) regarding how to parameterize the executor for how to execute specific languages.

You can fork from this branch to create your own PR. Then I can close this one.

I re-branch your branch and then I created an empty commit but I was denied.

@ekzhu
Copy link
Collaborator Author

ekzhu commented Apr 18, 2024

@asandez1 hmm, can you fork the Microsoft repo to your own account, and then checkout this PR's branch. After you commit your changes, push to a new branch in your own fork. Then, create a PR to merge the branch on your own fork to the main branch in the Microsoft repo.

@asandez1
Copy link
Contributor

asandez1 commented Apr 21, 2024

@zjjott
I created the PR with the lang mapping and the tests
#2464

@ekzhu
Copy link
Collaborator Author

ekzhu commented Apr 21, 2024

Close as the work is continued in #2464

@ekzhu ekzhu closed this Apr 21, 2024
github-merge-queue bot pushed a commit that referenced this pull request Apr 24, 2024
…utor with Mapping executor/saver #2303  (#2464)

* Add support for HTML, CSS and Javascript in LocalCommandLineCodeExecutor

* init branch

* init branch

* feat: test code execution added

* fix: test update

* fix: test

* fix: policy test

* feat: default policy

---------

Co-authored-by: Eric Zhu <[email protected]>
jayralencar pushed a commit to jayralencar/autogen that referenced this pull request May 28, 2024
…utor with Mapping executor/saver microsoft#2303  (microsoft#2464)

* Add support for HTML, CSS and Javascript in LocalCommandLineCodeExecutor

* init branch

* init branch

* feat: test code execution added

* fix: test update

* fix: test

* fix: policy test

* feat: default policy

---------

Co-authored-by: Eric Zhu <[email protected]>
@ekzhu ekzhu deleted the ekzhu-code-executor-save-files branch September 25, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-execution execute generated code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Support More core language and make extension
7 participants