pinokiod 7.5.16 → 7.5.18
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.
- package/kernel/api/hf/index.js +31 -0
- package/package.json +1 -1
- package/script/index.js +3 -3
- package/server/index.js +1 -1
- package/test/hf-api.test.js +47 -0
package/kernel/api/hf/index.js
CHANGED
|
@@ -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
package/script/index.js
CHANGED
|
@@ -58,9 +58,9 @@ const server = new Server({
|
|
|
58
58
|
return `https://pinokiocomputer.github.io/home/item?uri=${gitRemote}&display=profile`
|
|
59
59
|
},
|
|
60
60
|
site: "https://pinokio.co",
|
|
61
|
-
discover_dark: "https://
|
|
62
|
-
discover_light: "https://
|
|
63
|
-
portal: "https://
|
|
61
|
+
discover_dark: "https://pinokio.co?embed=1&theme=dark",
|
|
62
|
+
discover_light: "https://pinokio.co?embed=1&theme=light",
|
|
63
|
+
portal: "https://pinokio.co",
|
|
64
64
|
docs: "https://pinokio.co/docs",
|
|
65
65
|
install: "https://pinokiocomputer.github.io/program.pinokio.computer/#/?id=install",
|
|
66
66
|
agent: "web",
|
package/server/index.js
CHANGED
|
@@ -48,7 +48,7 @@ const DEFAULT_PORT = 42000
|
|
|
48
48
|
const NOTIFICATION_SOUND_EXTENSIONS = new Set(['.aac', '.flac', '.m4a', '.mp3', '.ogg', '.wav', '.webm'])
|
|
49
49
|
const LOG_STREAM_INITIAL_BYTES = 512 * 1024
|
|
50
50
|
const LOG_STREAM_KEEPALIVE_MS = 25000
|
|
51
|
-
const DEFAULT_REGISTRY_URL = 'https://
|
|
51
|
+
const DEFAULT_REGISTRY_URL = 'https://pinokio.co'
|
|
52
52
|
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '::1', '[::1]'])
|
|
53
53
|
const NON_INTERACTIVE_GIT_ENV = {
|
|
54
54
|
GIT_TERMINAL_PROMPT: "0",
|
package/test/hf-api.test.js
CHANGED
|
@@ -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
|
|