From 8bfeeab50e29a08ed4f6dbfbc254221986d0b263 Mon Sep 17 00:00:00 2001 From: Ariel Stolerman Date: Mon, 4 Nov 2024 00:34:17 -0800 Subject: [PATCH] [spidermate][code executor] add csharp support Summary: Added C# support, based off the AWS service: https://fburl.com/ngnfc9f3 - using mcs (instead of csc that the AWS service is using) for compilation, and mono for execution. Note, the image wouldn't build due to mono-core breaking rpm scripts. Added bypass and follow-up task T206575712. Test Plan: # UTs Added UTs: ``` [stolerman@devvm32682.lla0 ~/fbsource/fbcode/spidermate/code_executor (csharp)]$ buck test code_handler:test_code_handlers ``` https://www.internalfb.com/intern/testinfra/testrun/14918173821638790 # tested on local server Built and ran vaagent with the updated image: ``` [stolerman@devvm32682.lla0 ~/fbsource/fbcode (csharp)]$ buck2 run mode/opt //crackerjack/vaagent/:run_vaagent -- spidermate_execution_env --image //crackerjack/vaagent/image/execution_env/:rootfs.ext3 ``` Pointed the service to the local vaagent in the vmaas engine: ``` client = create_vaagent_client( # ip=None, # port=None, # tiername=VMAAS_TIER, # NOTE: comment out the above 3 lines and uncomment the below lines to run locally # (see https://www.internalfb.com/intern/wiki/Spidermate/Code_Executor/#add-dependencies-to-the) ip="127.0.0.1", port=9001, tiername=None, ) ``` Ran the service: ``` [stolerman@devvm32682.lla0 ~/fbsource/fbcode/spidermate/code_executor (csharp)]$ TW_PORT_thrift=54127 buck run mode/opt //spidermate/code_executor:service ``` Ran tests on thrift fiddle: ## (1) simple hello world **Endpoint:** `devvm32682.lla0.facebook.com:54127` **Method:** `executeCode` **Request Body** ```lang=json { "execute_code_request": { "code": { "code_snippet": { "snippet": "using System;\n\nnamespace HelloWorld\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.WriteLine(\"hello world!\");\n }\n }\n}\n", "language": "CSHARP", } } } } ``` **Request Headers** ```lang=json {"client_id":"test"} ``` **Response Body** ```lang=json { "process_output": { "exitCode": 0, "stdout": [ "hello world!" ], "stderr": [] } } ``` [Load request in Thrift Fiddle](https://fburl.com/thrift_fiddle/2ov2ozm2) ## (2) using refs Ran another test using `System.Numerics` from the provided references: **Endpoint:** `devvm32682.lla0.facebook.com:54127` **Method:** `executeCode` **Request Body** ```lang=json { "execute_code_request": { "code": { "code_snippet": { "snippet": "using System;\nusing System.Numerics;\n\nnamespace HelloWorld\n{\n class Program\n {\n static void Main(string[] args)\n {\n Vector2 a = new Vector2(1f, 1f);\n Vector2 b = new Vector2(2f, 2f);\n Console.WriteLine(a + b);\n }\n }\n}\n", "language": "CSHARP", } } } } ``` **Request Headers** ```lang=json {"client_id":"test"} ``` **Response Body** ```lang=json { "process_output": { "exitCode": 0, "stdout": [ "<3, 3>" ], "stderr": [] } } ``` [Load request in Thrift Fiddle](https://fburl.com/thrift_fiddle/nuxqx87r) ## (3) specifying main class **Endpoint:** `devvm32682.lla0.facebook.com:54127` **Method:** `executeCode` **Request Body** ```lang=json { "execute_code_request": { "code": { "code_snippet": { "snippet": "using System;\n\nnamespace HelloWorld\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.WriteLine(\"hello world!\");\n }\n }\n}\n", "language": "CSHARP", "properties": {"CSHARP__CLASS": "HelloWorld.Program"}, } } } } ``` **Request Headers** ```lang=json {"client_id":"test"} ``` **Response Body** ```lang=json { "process_output": { "exitCode": 0, "stdout": [ "hello world!" ], "stderr": [] } } ``` [Load request in Thrift Fiddle](https://fburl.com/thrift_fiddle/fhdmwtf9) ## (4) specifying wrong main class **Endpoint:** `devvm32682.lla0.facebook.com:54127` **Method:** `executeCode` **Request Body** ```lang=json { "execute_code_request": { "code": { "code_snippet": { "snippet": "using System;\n\nnamespace HelloWorld\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.WriteLine(\"hello world!\");\n }\n }\n}\n", "language": "CSHARP", "properties": {"CSHARP__CLASS": "HelloWorld.IDontExist"}, } } } } ``` **Request Headers** ```lang=json {"client_id":"test"} ``` **Response Body** ```lang=json { "process_output": { "exitCode": 1, "stdout": [ "Compilation failed: 1 error(s), 0 warnings" ], "stderr": [ "error CS1555: Could not find `HelloWorld.IDontExist' specified for Main method" ] } } ``` [Load request in Thrift Fiddle](https://fburl.com/thrift_fiddle/hvjcfyox) Reviewed By: azarian Differential Revision: D65397190 fbshipit-source-id: 2d78e44e1621eaec3884c23f9973201c0ed1e33d --- antlir/antlir2/features/rpm/driver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/antlir/antlir2/features/rpm/driver.py b/antlir/antlir2/features/rpm/driver.py index 630fb640b97..2665258ac90 100755 --- a/antlir/antlir2/features/rpm/driver.py +++ b/antlir/antlir2/features/rpm/driver.py @@ -101,6 +101,7 @@ def package_struct(pkg): "git-lfs": "TODO(T170621965)", "nsight-compute-2019.4.0": "TODO(T166170831)", "coreutils-common": "TODO(T182347179)", + "mono-core": "TODO(T206575712)", }