mirror of
https://github.com/tig-foundation/tig-monorepo.git
synced 2026-02-21 10:27:49 +08:00
Fix parsing of race_id.
This commit is contained in:
parent
652aa6d6f7
commit
b7d116666d
@ -52,7 +52,7 @@ if __name__ == "__main__":
|
||||
tig_verifier_path = shutil.which("tig-verifier")
|
||||
parser = argparse.ArgumentParser(description="TIG Algorithm Tester")
|
||||
parser.add_argument("algorithm", type=str, help="Algorithm name")
|
||||
parser.add_argument("size", type=int, help="Size of the problem instance")
|
||||
parser.add_argument("race_id", type=str, help="Race Id of the problem instance, comma separated key-values (e.g. a=1,b=2)")
|
||||
parser.add_argument("hyperparameters", type=str, help="JSON string of hyperparameters for the algorithm (can set to null)")
|
||||
parser.add_argument("--tig-runtime-path", type=str, default=tig_runtime_path, help=f"Path to tig-runtime executable (default: {tig_runtime_path})")
|
||||
parser.add_argument("--tig-verifier-path", type=str, default=tig_verifier_path, help=f"Path to tig-verifier executable (default: {tig_verifier_path})")
|
||||
@ -103,7 +103,7 @@ f"""Library not found at {so_path}:
|
||||
}
|
||||
challenge_id = challenge_ids[CHALLENGE]
|
||||
|
||||
settings = {"algorithm_id": "", "challenge_id": challenge_id, "size": args.size, "block_id": "", "player_id": ""}
|
||||
settings = {"algorithm_id": "", "challenge_id": challenge_id, "race_id": args.race_id, "block_id": "", "player_id": ""}
|
||||
pool = ThreadPoolExecutor(max_workers=args.workers + 1)
|
||||
|
||||
results = {}
|
||||
|
||||
@ -186,7 +186,7 @@ class ChallengeState(FromDict):
|
||||
@dataclass
|
||||
class ChallengeBlockData(FromDict):
|
||||
num_qualifiers: int
|
||||
qualifier_difficulties: Set[Point]
|
||||
qualifier_qualities: Dict[str, List[int]]
|
||||
|
||||
@dataclass
|
||||
class Challenge(FromDict):
|
||||
|
||||
@ -141,8 +141,8 @@
|
||||
</div>
|
||||
</td>
|
||||
<td class="row-cell">
|
||||
<div class="flex justify-content-center align-items-center">
|
||||
[innerHTML]="formatRaceId(benchmark.race_id)">
|
||||
<div class="flex justify-content-center align-items-center multiline">
|
||||
{{ benchmark.race_id_display }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="row-cell">
|
||||
|
||||
@ -78,3 +78,7 @@
|
||||
.tig-header {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.multiline {
|
||||
white-space: pre-line;
|
||||
}
|
||||
@ -123,11 +123,4 @@ export class HomeComponent {
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
}
|
||||
|
||||
formatRaceId(value: string): string {
|
||||
if (!value) return '';
|
||||
return value
|
||||
.replace(/=/g, ': ')
|
||||
.replace(/,/g, '<br>');
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,8 +100,13 @@ export class TigApisService {
|
||||
};
|
||||
});
|
||||
|
||||
const race_id_display = b.race_id
|
||||
.replace(/=/g, ': ')
|
||||
.replace(/,/g, '\n');
|
||||
|
||||
return {
|
||||
...b,
|
||||
race_id_display,
|
||||
time_elapsed,
|
||||
benchmark_id_display,
|
||||
batches,
|
||||
|
||||
@ -116,7 +116,12 @@ pub fn compute_solution(
|
||||
) -> Result<()>>(b"entry_point")?
|
||||
};
|
||||
|
||||
let race = dejsonify(&settings.race_id).map_err(|_| {
|
||||
let race_id = if settings.race_id.starts_with('"') && settings.race_id.ends_with('"') {
|
||||
settings.race_id.clone()
|
||||
} else {
|
||||
format!(r#""{}""#, settings.race_id)
|
||||
};
|
||||
let race = serde_json::from_str(&race_id).map_err(|_| {
|
||||
anyhow::anyhow!(
|
||||
"Failed to parse race_id '{}' as {}::Race",
|
||||
settings.race_id,
|
||||
|
||||
@ -64,7 +64,12 @@ pub fn verify_solution(
|
||||
|
||||
macro_rules! dispatch_challenge {
|
||||
($c:ident, cpu) => {{
|
||||
let race = dejsonify(&settings.race_id).map_err(|_| {
|
||||
let race_id = if settings.race_id.starts_with('"') && settings.race_id.ends_with('"') {
|
||||
settings.race_id.clone()
|
||||
} else {
|
||||
format!(r#""{}""#, settings.race_id)
|
||||
};
|
||||
let race = serde_json::from_str(&race_id).map_err(|_| {
|
||||
anyhow::anyhow!(
|
||||
"Failed to parse race_id '{}' as {}::Race",
|
||||
settings.race_id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user