Skip to content

Commit

Permalink
Make CPU's float
Browse files Browse the repository at this point in the history
  • Loading branch information
PineappleIOnic committed Aug 6, 2024
1 parent 6d474de commit a53ddb9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 56 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ docker compose down
| `command` | `string` | Commands to run after container is created. Maximum of 100 commands are allowed, each 1024 characters long. | | ' ' |
| `timeout` | `integer` | Commands execution time in seconds | | 600 |
| `remove` | `boolean` | Remove a runtime after execution | | false |
| `cpus` | `integer` | Maximum CPU cores runtime can utilize | | 1 |
| `cpus` | `float` | Maximum CPU cores runtime can utilize | | 1 |
| `memory` | `integer` | Container RAM memory in MBs | | 512 |
| `version` | `string` | Runtime Open Runtime version (allowed values: 'v2', 'v3') | | 'v3' |

Expand All @@ -175,7 +175,7 @@ docker compose down
| `source` | `string` | Path to source files | | ' ' |
| `entrypoint` | `string` | Entrypoint of the code file | | ' ' |
| `variables` | `json` | Environment variables passed into runtime | | [ ] |
| `cpus` | `integer` | Maximum CPU cores runtime can utilize | | 1 |
| `cpus` | `float` | Maximum CPU cores runtime can utilize | | 1 |
| `memory` | `integer` | Container RAM memory in MBs | | 512 |
| `version` | `string` | Runtime Open Runtime version (allowed values: 'v2', 'v3') | | 'v3' |
| `runtimeEntrypoint` | `string` | Commands to run when creating a container. Maximum of 100 commands are allowed, each 1024 characters long. | | ' ' |
Expand Down
9 changes: 5 additions & 4 deletions app/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use Utopia\Http\Route;
use Utopia\Http\Validator\Assoc;
use Utopia\Http\Validator\Boolean;
use Utopia\Http\Validator\FloatValidator;
use Utopia\Http\Validator\Integer;
use Utopia\Http\Validator\Text;
use Utopia\Http\Validator\WhiteList;
Expand Down Expand Up @@ -384,14 +385,14 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration):
->param('command', '', new Text(1024), 'Commands to run after container is created. Maximum of 100 commands are allowed, each 1024 characters long.', true)
->param('timeout', 600, new Integer(), 'Commands execution time in seconds.', true)
->param('remove', false, new Boolean(), 'Remove a runtime after execution.', true)
->param('cpus', 1, new Integer(), 'Container CPU.', true)
->param('cpus', 1.0, new FloatValidator(), 'Container CPU.', true)
->param('memory', 512, new Integer(), 'Comtainer RAM memory.', true)
->param('version', 'v3', new WhiteList(['v2', 'v3']), 'Runtime Open Runtime version.', true)
->inject('orchestration')
->inject('activeRuntimes')
->inject('response')
->inject('log')
->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, array $variables, string $runtimeEntrypoint, string $command, int $timeout, bool $remove, int $cpus, int $memory, string $version, Orchestration $orchestration, Table $activeRuntimes, Response $response, Log $log) {
->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, array $variables, string $runtimeEntrypoint, string $command, int $timeout, bool $remove, float $cpus, int $memory, string $version, Orchestration $orchestration, Table $activeRuntimes, Response $response, Log $log) {
$runtimeName = System::getHostname() . '-' . $runtimeId;

$runtimeHostname = \uniqid();
Expand Down Expand Up @@ -711,15 +712,15 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration):
->param('source', '', new Text(0), 'Path to source files.', true)
->param('entrypoint', '', new Text(256), 'Entrypoint of the code file.', true)
->param('variables', [], new Assoc(), 'Environment variables passed into runtime.', true)
->param('cpus', 1, new Integer(), 'Container CPU.', true)
->param('cpus', 1.0, new FloatValidator(), 'Container CPU.', true)
->param('memory', 512, new Integer(), 'Container RAM memory.', true)
->param('version', 'v3', new WhiteList(['v2', 'v3']), 'Runtime Open Runtime version.', true)
->param('runtimeEntrypoint', '', new Text(1024, 0), 'Commands to run when creating a container. Maximum of 100 commands are allowed, each 1024 characters long.', true)
->inject('activeRuntimes')
->inject('response')
->inject('log')
->action(
function (string $runtimeId, ?string $payload, string $path, string $method, array $headers, int $timeout, string $image, string $source, string $entrypoint, array $variables, int $cpus, int $memory, string $version, string $runtimeEntrypoint, Table $activeRuntimes, Response $response, Log $log) {
function (string $runtimeId, ?string $payload, string $path, string $method, array $headers, int $timeout, string $image, string $source, string $entrypoint, array $variables, float $cpus, int $memory, string $version, string $runtimeEntrypoint, Table $activeRuntimes, Response $response, Log $log) {
if (empty($payload)) {
$payload = '';
}
Expand Down
102 changes: 52 additions & 50 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a53ddb9

Please sign in to comment.