nebius/SWE-bench-extra huggingface dataset:
Repository: rorodata/firefly

Issue:
Allow firefly to support multiple functions
It should take multiple functions as command line arguments and expose all of them.

```
$ firefly myfile.square myfile.cube
```
And use:

```
$ curl -d '{"x": 5}' http://localhost:8000/square
25
$ curl -d '{"x": 5}' http://localhost:8000/cube
125
```

Comments:

Patch:
diff --git a/firefly/main.py b/firefly/main.py
index bb06d97..37eb583 100644
--- a/firefly/main.py
+++ b/firefly/main.py
@@ -7,7 +7,7 @@ from .server import FireflyServer
 def parse_args():
     p = argparse.ArgumentParser()
     p.add_argument("-b", "--bind", dest="ADDRESS", default="127.0.0.1:8000")
-    p.add_argument("function", help="function to serve")
+    p.add_argument("functions", nargs='+', help="functions to serve")
     return p.parse_args()
 
 def load_function(function_spec):
@@ -17,7 +17,14 @@ def load_function(function_spec):
     mod_name, func_name = function_spec.rsplit(".", 1)
     mod = importlib.import_module(mod_name)
     func = getattr(mod, func_name)
-    return func
+    return (func_name, func)
+
+def load_functions(function_specs):
+    return [load_function(function_spec) for function_spec in function_specs]
+
+def add_routes(app, functions):
+    for name, function in functions:
+        app.add_route('/'+name, function)
 
 def main():
     # ensure current directory is added to sys.path
@@ -25,10 +32,10 @@ def main():
         sys.path.insert(0, "")
 
     args = parse_args()
-    function = load_function(args.function)
+    functions = load_functions(args.functions)
 
     app = Firefly()
-    app.add_route("/", function)
+    add_routes(app, functions)
 
     server = FireflyServer(app, {"bind": args.ADDRESS})
     server.run()


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
new file mode 100644
index 0000000..7ecfbf2
--- /dev/null
+++ b/tests/test_main.py
@@ -0,0 +1,8 @@
+import os
+from firefly.main import load_function
+
+def test_load_functions():
+    os.path.exists2 = os.path.exists
+    name, func = load_function("os.path.exists2")
+    assert name == "exists2"
+    assert func == os.path.exists