-
Notifications
You must be signed in to change notification settings - Fork 1
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
Make CPU's float #91
Make CPU's float #91
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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(); | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use $cpus in Notice it accepts int. We need to change orchestration library to support float too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeap we updated it 👍 Release 0.10.1 of it |
||
if (empty($payload)) { | ||
$payload = ''; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename it to
Float
? It's already in namespace ofValidator
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its actually called FloatValidator in the http library
https://github.com/utopia-php/http/blob/master/src/Http/Validator/FloatValidator.php
We need to fix it there.
For now we can do
use Utopia\Http\Validator\FloatValidator as Float;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't do either (I wanted to do this previously 😅) Class names are case-insensitive in PHP, and classes named 'int', 'string', 'float', 'bool', 'true', 'false', or 'null' are forbidden