pinokiod 7.5.16 → 7.5.17

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.
@@ -327,5 +327,36 @@ class HF {
327
327
  let res = await shell.run(req, ondata, kernel)
328
328
  return res
329
329
  }
330
+ /*
331
+ {
332
+ "method": "hf.upload",
333
+ "params": {
334
+ path: <cwd>,
335
+ env: {
336
+ <env1>: <val1>,
337
+ <env1>: <val1>,
338
+ <env1>: <val1>,
339
+ },
340
+ _: [<command line args>'],
341
+ <arg1>: <val1>,
342
+ <arg2>: <val2>,
343
+ ...
344
+ }
345
+ }
346
+ */
347
+ async upload(req, ondata, kernel) {
348
+ const shell = new Shell()
349
+ let params = Object.assign({}, req.params)
350
+ delete params.env
351
+ delete params.path
352
+ const positional = Array.isArray(params._) ? params._ : (params._ == null ? [] : [params._])
353
+ params._ = ["hf", "upload", ...positional]
354
+ let message = [
355
+ params
356
+ ]
357
+ req.params.message = message
358
+ let res = await shell.run(req, ondata, kernel)
359
+ return res
360
+ }
330
361
  }
331
362
  module.exports = HF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "7.5.16",
3
+ "version": "7.5.17",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -408,6 +408,53 @@ test('hf.logout delegates to the Hugging Face connect provider and returns succe
408
408
  assert.deepEqual(calls, [{ method: 'logout', provider: 'huggingface', params: req.params }])
409
409
  })
410
410
 
411
+ test('hf.upload runs hf upload through shell.run with Hugging Face CLI args', async () => {
412
+ const hf = new HF()
413
+ const calls = []
414
+ const kernel = {
415
+ platform: 'darwin',
416
+ shell: {
417
+ async run(params, options) {
418
+ calls.push({
419
+ params,
420
+ options
421
+ })
422
+ return { status: 'success' }
423
+ }
424
+ }
425
+ }
426
+ const req = {
427
+ cwd: '/pinokio/api/test',
428
+ parent: { id: 'test-script' },
429
+ params: {
430
+ path: '/pinokio/api/test/output',
431
+ env: { TEST_ENV: '1' },
432
+ _: ['cocktailpeanut/privatetest', './output', '.'],
433
+ 'repo-type': 'dataset',
434
+ private: true,
435
+ 'commit-message': 'initial upload'
436
+ }
437
+ }
438
+
439
+ const result = await hf.upload(req, () => {}, kernel)
440
+
441
+ assert.deepEqual(result, { status: 'success' })
442
+ assert.equal(calls.length, 1)
443
+ assert.deepEqual(calls[0].params.message, [
444
+ {
445
+ _: ['hf', 'upload', 'cocktailpeanut/privatetest', './output', '.'],
446
+ 'repo-type': 'dataset',
447
+ private: true,
448
+ 'commit-message': 'initial upload'
449
+ }
450
+ ])
451
+ assert.deepEqual(calls[0].params.env, { TEST_ENV: '1' })
452
+ assert.equal(calls[0].params.path, '/pinokio/api/test/output')
453
+ assert.equal(calls[0].params.bluefairy, 'off')
454
+ assert.equal(calls[0].options.cwd, '/pinokio/api/test')
455
+ assert.equal(calls[0].options.group, 'test-script')
456
+ })
457
+
411
458
  test('hf.login reports unavailable Hugging Face connect provider', async () => {
412
459
  const hf = new HF()
413
460