diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 075dfc6499..7a49c70fcc 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -942,7 +942,6 @@ App::post('/v1/functions/:functionId/executions') try { $executionResponse = $executor->createExecution( projectId: $project->getId(), - functionId: $function->getId(), deploymentId: $deployment->getId(), path: $build->getAttribute('outputPath', ''), vars: $vars, @@ -967,11 +966,10 @@ App::post('/v1/functions/:functionId/executions') } Authorization::skip(fn() => $dbForProject->updateDocument('executions', $executionId, $execution)); - $executionResponse['response'] = ($executionResponse['status'] !== 'completed') ? $executionResponse['stderr'] : $executionResponse['stdout']; $response ->setStatusCode(Response::STATUS_CODE_CREATED) - ->dynamic(new Document($executionResponse), Response::MODEL_SYNC_EXECUTION); + ->dynamic($execution, Response::MODEL_EXECUTION); }); App::get('/v1/functions/:functionId/executions') diff --git a/app/executor.php b/app/executor.php index fe93f37876..d9be75dca7 100644 --- a/app/executor.php +++ b/app/executor.php @@ -395,17 +395,13 @@ App::delete('/v1/runtimes/:runtimeId') App::post('/v1/execution') ->desc('Create an execution') ->param('runtimeId', '', new Text(64), 'The runtimeID to execute') - ->param('path', '', new Text(0), 'Path containing the built files.', false) ->param('vars', [], new Assoc(), 'Environment variables required for the build', false) ->param('data', '', new Text(8192), 'Data to be forwarded to the function, this is user specified.', true) - ->param('runtime', '', new Text(128), 'Runtime for the cloud function', false) - ->param('entrypoint', '', new Text(256), 'Entrypoint of the code file') ->param('timeout', 15, new ValidatorRange(1, 900), 'Function maximum execution time in seconds.', true) - ->param('baseImage', '', new Text(128), 'Base image name of the runtime', false) ->inject('activeRuntimes') ->inject('response') ->action( - function (string $runtimeId, string $path, array $vars, string $data, string $runtime, string $entrypoint, $timeout, string $baseImage, $activeRuntimes, Response $response) { + function (string $runtimeId, array $vars, string $data, $timeout, $activeRuntimes, Response $response) { if (!$activeRuntimes->exists($runtimeId)) { throw new Exception('Runtime not found. Please create the runtime.', 404); diff --git a/app/workers/builds.php b/app/workers/builds.php index a213cfdec4..6e3b56880e 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -114,7 +114,6 @@ class BuildsV1 extends Worker try { $response = $this->executor->createRuntime( projectId: $projectId, - functionId: $functionId, deploymentId: $deploymentId, entrypoint: $deployment->getAttribute('entrypoint'), source: $source, diff --git a/app/workers/functions.php b/app/workers/functions.php index c98dae63f0..d98160f151 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -290,7 +290,6 @@ class FunctionsV1 extends Worker try { $executionResponse = $this->executor->createExecution( projectId: $projectId, - functionId: $functionId, deploymentId: $deploymentId, path: $build->getAttribute('outputPath', ''), vars: $vars, diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 32375af358..4d67302f38 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -31,7 +31,6 @@ use Appwrite\Utopia\Response\Model\Domain; use Appwrite\Utopia\Response\Model\Error; use Appwrite\Utopia\Response\Model\ErrorDev; use Appwrite\Utopia\Response\Model\Execution; -use Appwrite\Utopia\Response\Model\SyncExecution; use Appwrite\Utopia\Response\Model\Build; use Appwrite\Utopia\Response\Model\File; use Appwrite\Utopia\Response\Model\Bucket; @@ -156,7 +155,6 @@ class Response extends SwooleResponse const MODEL_DEPLOYMENT = 'deployment'; const MODEL_DEPLOYMENT_LIST = 'deploymentList'; const MODEL_EXECUTION = 'execution'; - const MODEL_SYNC_EXECUTION = 'syncExecution'; const MODEL_EXECUTION_LIST = 'executionList'; const MODEL_BUILD = 'build'; const MODEL_BUILD_LIST = 'buildList'; @@ -268,7 +266,6 @@ class Response extends SwooleResponse ->setModel(new Runtime()) ->setModel(new Deployment()) ->setModel(new Execution()) - ->setModel(new SyncExecution()) ->setModel(new Build()) ->setModel(new Project()) ->setModel(new Webhook()) diff --git a/src/Appwrite/Utopia/Response/Model/SyncExecution.php b/src/Appwrite/Utopia/Response/Model/SyncExecution.php deleted file mode 100644 index 05220f78fd..0000000000 --- a/src/Appwrite/Utopia/Response/Model/SyncExecution.php +++ /dev/null @@ -1,53 +0,0 @@ -addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Execution Status.', - 'default' => '', - 'example' => 'completed', - ]) - ->addRule('response', [ - 'type' => self::TYPE_STRING, - 'description' => 'Execution Response.', - 'default' => '', - 'example' => 'Hello World!', - ]) - ->addRule('time', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Execution Time.', - 'default' => 0, - 'example' => 100, - ]) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName():string - { - return 'Syncronous Execution'; - } - - /** - * Get Collection - * - * @return string - */ - public function getType():string - { - return Response::MODEL_SYNC_EXECUTION; - } -} \ No newline at end of file diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index c731a9ab9c..2bdad22e8f 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -36,7 +36,6 @@ class Executor * * Launches a runtime container for a deployment ready for execution * - * @param string $functionId * @param string $deploymentId * @param string $projectId * @param string $source @@ -51,7 +50,6 @@ class Executor * @param array $commands */ public function createRuntime( - string $functionId, string $deploymentId, string $projectId, string $source, @@ -127,7 +125,6 @@ class Executor * Create an execution * * @param string $projectId - * @param string $functionId * @param string $deploymentId * @param string $path * @param array $vars @@ -141,7 +138,6 @@ class Executor */ public function createExecution( string $projectId, - string $functionId, string $deploymentId, string $path, array $vars, @@ -158,13 +154,9 @@ class Executor ]; $params = [ 'runtimeId' => "$projectId-$deploymentId", - 'path' => $path, 'vars' => $vars, 'data' => $data, - 'runtime' => $runtime, - 'entrypoint' => $entrypoint, 'timeout' => $timeout, - 'baseImage' => $baseImage, ]; $response = $this->call(self::METHOD_POST, $route, $headers, $params, true, 30); @@ -175,7 +167,6 @@ class Executor switch ($status) { case 404: $response = $this->createRuntime( - functionId: $functionId, deploymentId: $deploymentId, projectId: $projectId, source: $path, diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index bedeee6ed6..d2443783c0 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -383,7 +383,7 @@ class FunctionsCustomClientTest extends Scope 'async' => false ]); - $output = json_decode($execution['body']['response'], true); + $output = json_decode($execution['body']['stdout'], true); $this->assertEquals(201, $execution['headers']['status-code']); $this->assertEquals('completed', $execution['body']['status']); $this->assertEquals($functionId, $output['APPWRITE_FUNCTION_ID']); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 9a2afde739..1654fd4af4 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -594,12 +594,12 @@ class FunctionsCustomServerTest extends Scope ]); $this->assertEquals('completed', $execution['body']['status']); - $this->assertStringContainsString($data['deploymentId'], $execution['body']['response']); - $this->assertStringContainsString('Test1', $execution['body']['response']); - $this->assertStringContainsString('http', $execution['body']['response']); - $this->assertStringContainsString('PHP', $execution['body']['response']); - $this->assertStringContainsString('8.0', $execution['body']['response']); - // $this->assertStringContainsString('êä', $execution['body']['response']); // tests unknown utf-8 chars + $this->assertStringContainsString($data['deploymentId'], $execution['body']['stdout']); + $this->assertStringContainsString('Test1', $execution['body']['stdout']); + $this->assertStringContainsString('http', $execution['body']['stdout']); + $this->assertStringContainsString('PHP', $execution['body']['stdout']); + $this->assertStringContainsString('8.0', $execution['body']['stdout']); + // $this->assertStringContainsString('êä', $execution['body']['sdtout']); // tests unknown utf-8 chars $this->assertLessThan(0.500, $execution['body']['time']); return $data;