add limit overrides to runtime definitions
This commit is contained in:
parent
8d6ecfaf37
commit
ddab59ccdd
|
@ -46,7 +46,7 @@ const { Job } = require('../job');
|
||||||
...metadata,
|
...metadata,
|
||||||
...runtime.Runtime.compute_all_limits(
|
...runtime.Runtime.compute_all_limits(
|
||||||
metadata.language,
|
metadata.language,
|
||||||
metadata.limit_overrides
|
metadata.limitOverrides
|
||||||
),
|
),
|
||||||
flake_path: runtime_path,
|
flake_path: runtime_path,
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,6 @@ const path = require('path');
|
||||||
|
|
||||||
const runtimes = [];
|
const runtimes = [];
|
||||||
|
|
||||||
|
|
||||||
class Runtime {
|
class Runtime {
|
||||||
constructor({
|
constructor({
|
||||||
language,
|
language,
|
||||||
|
@ -23,7 +22,7 @@ class Runtime {
|
||||||
max_process_count,
|
max_process_count,
|
||||||
max_open_files,
|
max_open_files,
|
||||||
max_file_size,
|
max_file_size,
|
||||||
output_max_size
|
output_max_size,
|
||||||
}) {
|
}) {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
|
@ -45,7 +44,6 @@ class Runtime {
|
||||||
this.package_support = packageSupport;
|
this.package_support = packageSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static compute_single_limit(
|
static compute_single_limit(
|
||||||
language_name,
|
language_name,
|
||||||
limit_name,
|
limit_name,
|
||||||
|
@ -109,25 +107,24 @@ class Runtime {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_built(){
|
ensure_built() {
|
||||||
logger.info(`Ensuring ${this} is built`);
|
logger.info(`Ensuring ${this} is built`);
|
||||||
|
|
||||||
const flake_path = this.flake_path;
|
const flake_path = this.flake_path;
|
||||||
|
|
||||||
function _ensure_built(key){
|
function _ensure_built(key) {
|
||||||
const command = `nix build ${flake_path}.metadata.${key} --no-link`;
|
const command = `nix build ${flake_path}.metadata.${key} --no-link`;
|
||||||
cp.execSync(command, {stdio: "pipe"})
|
cp.execSync(command, { stdio: 'pipe' });
|
||||||
}
|
}
|
||||||
|
|
||||||
_ensure_built("run");
|
_ensure_built('run');
|
||||||
if(this.compiled) _ensure_built("compile");
|
if (this.compiled) _ensure_built('compile');
|
||||||
|
|
||||||
logger.debug(`Finished ensuring ${this} is installed`)
|
|
||||||
|
|
||||||
|
logger.debug(`Finished ensuring ${this} is installed`);
|
||||||
}
|
}
|
||||||
|
|
||||||
static load_runtime(flake_key){
|
static load_runtime(flake_key) {
|
||||||
logger.info(`Loading ${flake_key}`)
|
logger.info(`Loading ${flake_key}`);
|
||||||
const flake_path = `${config.flake_path}#pistonRuntimeSets.${config.runtime_set}.${flake_key}`;
|
const flake_path = `${config.flake_path}#pistonRuntimeSets.${config.runtime_set}.${flake_key}`;
|
||||||
const metadata_command = `nix eval --json ${flake_path}.metadata`;
|
const metadata_command = `nix eval --json ${flake_path}.metadata`;
|
||||||
const metadata = JSON.parse(cp.execSync(metadata_command));
|
const metadata = JSON.parse(cp.execSync(metadata_command));
|
||||||
|
@ -136,35 +133,31 @@ class Runtime {
|
||||||
...metadata,
|
...metadata,
|
||||||
...Runtime.compute_all_limits(
|
...Runtime.compute_all_limits(
|
||||||
metadata.language,
|
metadata.language,
|
||||||
metadata.limit_overrides
|
metadata.limitOverrides
|
||||||
),
|
),
|
||||||
flake_path
|
flake_path,
|
||||||
});
|
});
|
||||||
|
|
||||||
this_runtime.ensure_built();
|
this_runtime.ensure_built();
|
||||||
|
|
||||||
runtimes.push(this_runtime);
|
runtimes.push(this_runtime);
|
||||||
|
|
||||||
|
|
||||||
logger.debug(`Package ${flake_key} was loaded`);
|
logger.debug(`Package ${flake_key} was loaded`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get compiled() {
|
get compiled() {
|
||||||
return this.compile !== null;
|
return this.compile !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get id(){
|
get id() {
|
||||||
return runtimes.indexOf(this);
|
return runtimes.indexOf(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
return `${this.language}-${this.version}`;
|
return `${this.language}-${this.version}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = runtimes;
|
module.exports = runtimes;
|
||||||
module.exports.Runtime = Runtime;
|
module.exports.Runtime = Runtime;
|
||||||
module.exports.load_runtime = Runtime.load_runtime;
|
module.exports.load_runtime = Runtime.load_runtime;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
compile? null,
|
compile? null,
|
||||||
packages? null,
|
packages? null,
|
||||||
aliases? [],
|
aliases? [],
|
||||||
|
limitOverrides? {},
|
||||||
tests
|
tests
|
||||||
}: let
|
}: let
|
||||||
compileFile = if compile != null then
|
compileFile = if compile != null then
|
||||||
|
@ -28,7 +29,7 @@
|
||||||
else null;
|
else null;
|
||||||
runFile = pkgs.writeShellScript "run" run;
|
runFile = pkgs.writeShellScript "run" run;
|
||||||
metadata = {
|
metadata = {
|
||||||
inherit language version runtime aliases;
|
inherit language version runtime aliases limitOverrides;
|
||||||
run = runFile;
|
run = runFile;
|
||||||
compile = compileFile;
|
compile = compileFile;
|
||||||
packageSupport = packages != null;
|
packageSupport = packages != null;
|
||||||
|
|
Loading…
Reference in New Issue