@quantum-hub/qhubctl 1.14.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,8 @@
1
1
  import { Command } from 'commander';
2
+ import { HubPlatform } from '@quantum-hub/qhub-api/platform';
3
+ export interface RunCommandOptions {
4
+ tag: string[];
5
+ storeInput: boolean;
6
+ }
7
+ export declare function buildCreateJobRequest(serviceId: string, input: Record<string, never> | undefined, opts: RunCommandOptions): HubPlatform.CreateServiceJobRequest;
2
8
  export declare const runCommand: Command;
@@ -1,6 +1,7 @@
1
1
  import { confirm } from '@inquirer/prompts';
2
2
  import { Command } from 'commander';
3
- import { waitUntil } from 'async-wait-until';
3
+ import asyncWaitUntil from 'async-wait-until';
4
+ const { waitUntil } = asyncWaitUntil;
4
5
  import fsExtra from 'fs-extra';
5
6
  const { readJsonSync } = fsExtra;
6
7
  import fs from 'node:fs';
@@ -39,18 +40,33 @@ async function getInputFromFiles(filePaths) {
39
40
  }
40
41
  return mergedInput;
41
42
  }
43
+ export function buildCreateJobRequest(serviceId, input, opts) {
44
+ const payload = {
45
+ serviceId,
46
+ tags: ['cli', ...opts.tag],
47
+ input,
48
+ };
49
+ if (opts.storeInput) {
50
+ payload.storeInput = true;
51
+ }
52
+ return payload;
53
+ }
42
54
  const EXAMPLES = `
43
55
  Examples:
44
56
  $ qhubctl run
45
57
  $ qhubctl run --detached
46
58
  $ qhubctl run -i '{"values": [10,12], "round_up": true}'
47
59
  $ qhubctl run --input-files=./input/data.json,./input/params.json
48
- $ qhubctl run --input-files=./config.json,./overrides.json`;
60
+ $ qhubctl run --input-files=./config.json,./overrides.json
61
+ $ qhubctl run --store-input
62
+ $ qhubctl run --tag experiment --tag run-42`;
49
63
  export const runCommand = new Command('run')
50
64
  .description('Creates a job execution')
51
65
  .argument('[serviceId]', 'The ID of the service to run (optional — reads from qhub.json if omitted)')
52
66
  .option('-i, --input <value>', 'Input as JSON string.')
53
67
  .option('--input-files <value>', 'Comma-separated paths to files containing input to be merged (default: ./input/data.json,./input/params.json).')
68
+ .option('--store-input', 'Persist the input data alongside the job on the server.', false)
69
+ .option('--tag <value>', 'Tag to attach to the job. Repeat the flag to attach multiple tags.', (value, previous) => [...previous, value], [])
54
70
  .option('--detached', 'Executes the job in detached mode, i.e., without waiting for it to finish.', false)
55
71
  .addHelpText('after', EXAMPLES)
56
72
  .action(async (serviceId, opts) => {
@@ -82,7 +98,7 @@ export const runCommand = new Command('run')
82
98
  input = await getInputFromFiles(opts.inputFiles || './input/data.json,./input/params.json');
83
99
  }
84
100
  let job;
85
- const payload = { serviceId: service.id, tags: ['cli'], input };
101
+ const payload = buildCreateJobRequest(service.id, input, { tag: opts.tag, storeInput: opts.storeInput });
86
102
  job = await hubService.runJob(payload);
87
103
  if (opts.detached) {
88
104
  stdout(`Job (${job.id}) created.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantum-hub/qhubctl",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "Kipu Quantum Hub CLI",
5
5
  "author": "Kipu Quantum GmbH",
6
6
  "contributors": [