pinokiod 3.2.198 → 3.2.200

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.
@@ -623,10 +623,26 @@ class Api {
623
623
 
624
624
  rpc.args = args
625
625
 
626
- if (i < script.run.length-1) {
627
- rpc.next = i+1
626
+ if (rpc.hasOwnProperty("next")) {
627
+ console.log("next already exists, don't touch", rpc.next)
628
+ if (typeof rpc.next === "string") {
629
+ let run = script.run
630
+ console.log("run", run)
631
+ for(let i=0; i<run.length; i++) {
632
+ let step = run[i]
633
+ if (step && step.id === rpc.next) {
634
+ rpc.next = i
635
+ break
636
+ }
637
+ }
638
+ }
628
639
  } else {
629
- rpc.next = null
640
+ if (i < script.run.length-1) {
641
+ rpc.next = i+1
642
+ } else {
643
+ rpc.next = null
644
+ }
645
+ console.log("next is not set. compute the next value", rpc.next)
630
646
  }
631
647
 
632
648
  if (rpc.hasOwnProperty("when")) {
@@ -64,7 +64,7 @@ class Local {
64
64
  */
65
65
 
66
66
  let current_env = await Environment.get2(req.parent.path, kernel)
67
- console.log({ current_env })
67
+ // console.log({ current_env })
68
68
 
69
69
  // if the key at current_env.PINOKIO_SHARE_VAR (by default it's 'url') is the variable being set, trigger the share logic
70
70
  if (current_env.PINOKIO_SHARE_VAR && current_env.PINOKIO_SHARE_VAR in req.params) {
@@ -96,13 +96,11 @@ create_default_packages:
96
96
  // console.log("conda list check", { stream })
97
97
  })
98
98
 
99
- console.log("CONDA", res.response)
100
99
  let lines = res.response.split(/[\r\n]+/)
101
100
  let conda_check = {}
102
101
  let conda = new Set()
103
102
  let start = false
104
103
  for(let line of lines) {
105
- console.log({ line, start })
106
104
  if (start) {
107
105
  let chunks = line.split(/\s+/).filter(x => x)
108
106
  if (chunks.length > 1) {
@@ -122,7 +120,6 @@ create_default_packages:
122
120
  let channel = chunks[3]
123
121
  let coerced = semver.coerce(version)
124
122
  let mamba_requirement = ">=24.11.1"
125
- console.log({ name, channel, version })
126
123
  if (semver.satisfies(coerced, mamba_requirement) && channel === "conda-forge") {
127
124
  conda_check.mamba = true
128
125
  }
@@ -133,7 +130,6 @@ create_default_packages:
133
130
  if (name === "sqlite") {
134
131
  let coerced = semver.coerce(version)
135
132
  let sqlite_requirement = ">=3.47.2"
136
- console.log({ coerced, version, sqlite_requirement })
137
133
  if (semver.satisfies(coerced, sqlite_requirement)) {
138
134
  console.log("semver satisfied")
139
135
  conda_check.sqlite = true
@@ -142,9 +142,7 @@ class Bin {
142
142
  this.vs_path_env = mod.mod.env(this.kernel)
143
143
  return null
144
144
  } else {
145
- console.log({ mod })
146
145
  if (mod.mod.env) {
147
- console.log("env", mod.mod.env)
148
146
  return mod.mod.env(this.kernel)
149
147
  } else {
150
148
  return null
@@ -243,10 +241,8 @@ class Bin {
243
241
  // console.log("conda list check", { stream })
244
242
  })
245
243
 
246
- console.log("CONDA", res.response)
247
244
  let lines = res.response.split(/[\r\n]+/)
248
245
  for(let line of lines) {
249
- console.log({ line, start })
250
246
  if (start) {
251
247
  let chunks = line.split(/\s+/).filter(x => x)
252
248
  if (chunks.length > 1) {
@@ -274,7 +270,7 @@ class Bin {
274
270
  if (name === "sqlite") {
275
271
  let coerced = semver.coerce(version)
276
272
  let sqlite_requirement = ">=3.47.2"
277
- console.log({ coerced, version, sqlite_requirement })
273
+ // console.log({ coerced, version, sqlite_requirement })
278
274
  if (semver.satisfies(coerced, sqlite_requirement)) {
279
275
  console.log("semver satisfied")
280
276
  conda_check.sqlite = true
@@ -325,38 +321,38 @@ class Bin {
325
321
  // Try 3 times, because sometimes conda just silently quits with no error message
326
322
  for(let i=0; i<5; i++) {
327
323
  await this.tryList()
328
- console.log(`> conda list ${i}`, Array.from(this.installed.conda))
324
+ // console.log(`> conda list ${i}`, Array.from(this.installed.conda))
329
325
  if (this.installed.conda.size > 0) {
330
326
  break
331
327
  }
332
328
  }
333
329
  }
334
330
 
335
- // 2. pip
336
- let pip = new Set()
337
- if (conda_exists) {
338
- // conda comes with pip
339
- console.log("## check pip")
340
- start = false
341
- res = await this.exec({ message: `pip list` }, (stream) => {
342
- // console.log("pip list check", { stream })
343
- })
344
- console.log("PIP", res.response)
345
- lines = res.response.split(/[\r\n]+/)
346
- for(let line of lines) {
347
- if (start) {
348
- let chunks = line.split(/\s+/).filter(x => x)
349
- if (chunks.length > 1) {
350
- pip.add(chunks[0])
351
- }
352
- } else {
353
- if (/-------.*/i.test(line)) {
354
- start = true
355
- }
356
- }
357
- }
358
- }
359
- this.installed.pip = pip
331
+ // // 2. pip
332
+ // let pip = new Set()
333
+ // if (conda_exists) {
334
+ // // conda comes with pip
335
+ // console.log("## check pip")
336
+ // start = false
337
+ // res = await this.exec({ message: `pip list` }, (stream) => {
338
+ //// console.log("pip list check", { stream })
339
+ // })
340
+ // console.log("PIP", res.response)
341
+ // lines = res.response.split(/[\r\n]+/)
342
+ // for(let line of lines) {
343
+ // if (start) {
344
+ // let chunks = line.split(/\s+/).filter(x => x)
345
+ // if (chunks.length > 1) {
346
+ // pip.add(chunks[0])
347
+ // }
348
+ // } else {
349
+ // if (/-------.*/i.test(line)) {
350
+ // start = true
351
+ // }
352
+ // }
353
+ // }
354
+ // }
355
+ // this.installed.pip = pip
360
356
 
361
357
 
362
358
  if (this.platform === "darwin") {
@@ -427,7 +423,7 @@ class Bin {
427
423
  } else {
428
424
  e4 = false
429
425
  }
430
- console.log({ e, e2, e3, e4, stdout })
426
+ console.log("BREW CHECK", { e, e2, e3, e4 })
431
427
  this.brew_installed = e && e2 && e3 && e4
432
428
 
433
429
  }
@@ -644,7 +640,7 @@ class Bin {
644
640
  if (type === "conda") {
645
641
  return this.kernel.bin.installed.conda.has(name)
646
642
  } else if (type === "pip") {
647
- return this.kernel.bin.installed.pip.has(name)
643
+ return this.kernel.bin.installed.pip && this.kernel.bin.installed.pip.has(name)
648
644
  } else if (type === "brew") {
649
645
  return this.kernel.bin.installed.brew.has(name)
650
646
  } else {
package/kernel/index.js CHANGED
@@ -14,6 +14,7 @@ const Api = require("./api")
14
14
  const Python = require("./python")
15
15
  //const Template = require('./template')
16
16
  const Template = require('jimini')
17
+ const which = require('which')
17
18
  const Shells = require("./shells")
18
19
  const Key = require("./key")
19
20
  const Script = require('./script')
@@ -222,6 +223,25 @@ class Kernel {
222
223
  async wait(options) {
223
224
  await waitOn(options)
224
225
  }
226
+ async getInfo(){
227
+ let info = this.sysinfo
228
+ await this.update_sysinfo()
229
+ let i = {
230
+ platform: this.platform,
231
+ arch: this.arch,
232
+ running: this.api.running,
233
+ home: this.homedir,
234
+ vars: this.vars,
235
+ memory: this.memory,
236
+ procs: this.procs,
237
+ gpu: this.gpu,
238
+ gpus: this.gpus,
239
+ version: this.version,
240
+ ...info
241
+ }
242
+
243
+ this.i = i
244
+ }
225
245
 
226
246
  async synchronize_proxies() {
227
247
  let proxy_registry_path = path.resolve(this.homedir, "proxy_registry")
@@ -309,7 +329,6 @@ class Kernel {
309
329
  this.template = new Template()
310
330
  try {
311
331
  let grant_permission = false
312
- console.log(">>>>>> this.homedir", this.homedir)
313
332
  if (this.homedir) {
314
333
 
315
334
  // 0. create homedir
@@ -357,7 +376,10 @@ class Kernel {
357
376
  if (this.envs) {
358
377
  this.template.update({
359
378
  env: this.envs,
360
- envs: this.envs
379
+ envs: this.envs,
380
+ which: (name) => {
381
+ return which.sync(name, { nothrow: true, path: this.envs.PATH })
382
+ }
361
383
  })
362
384
  }
363
385
  // console.log({ grant_permission })
@@ -381,9 +403,7 @@ class Kernel {
381
403
 
382
404
  //await this.shell.init()
383
405
 
384
- console.log("homedir", this.homedir)
385
406
  if (this.homedir) {
386
- console.log("> 1")
387
407
  await this.template.init({
388
408
  kernel: this,
389
409
  system,
@@ -393,19 +413,16 @@ class Kernel {
393
413
  return this.api.get_proxy_url("/proxy", port)
394
414
  },
395
415
  })
396
- console.log("> 2")
397
416
  this.sys = new Sysinfo()
398
417
  await this.sys.init(this)
399
418
  let info = this.sys.info
400
- await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
401
- await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify({
402
- platform: this.platform,
403
- arch: this.arch,
404
- home: this.homedir,
405
- ...info
406
- }, null, 2))
419
+
407
420
  this.sysinfo = info
408
- await this.update_sysinfo()
421
+
422
+ await this.getInfo()
423
+
424
+ await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
425
+ await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
409
426
  /*
410
427
  this.sys = new Sysinfo()
411
428
  await this.sys.init(this)
package/kernel/shell.js CHANGED
@@ -659,7 +659,7 @@ class Shell {
659
659
  if (params.venv) {
660
660
  let env_path = path.resolve(params.path, params.venv)
661
661
  let activate_path = (this.platform === 'win32' ? path.resolve(env_path, "Scripts", "activate") : path.resolve(env_path, "bin", "activate"))
662
- let deactivate_path = (this.platform === 'win32' ? path.resolve(env_path, "Scripts", "deactivate") : path.resolve(env_path, "bin", "deactivate"))
662
+ let deactivate_path = (this.platform === 'win32' ? path.resolve(env_path, "Scripts", "deactivate") : "deactivate")
663
663
  let env_exists = await this.exists(env_path)
664
664
  if (env_exists) {
665
665
  venv_activation = [
@@ -671,7 +671,7 @@ class Shell {
671
671
  `python -m venv ${env_path}`,
672
672
  (this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
673
673
  `python -m pip install --upgrade pip setuptools wheel`,
674
- (this.platform === "win32" ? `${deactivate_path}` : `source ${deactivate_path}`),
674
+ deactivate_path,
675
675
  (this.platform === 'win32' ? `${timeout} /t 1 > nul` : 'sleep 1'),
676
676
  (this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
677
677
  (this.platform === 'win32' ? `${timeout} /t 1 > nul` : 'sleep 1'),
@@ -721,9 +721,9 @@ class Shell {
721
721
  this.queue.push(data)
722
722
  }
723
723
  });
724
- this.ptyProcess.onExit((result) => {
725
- console.log(">>>>>>>>>>>>>>>>>>> exec onExit", result)
726
- })
724
+ // this.ptyProcess.onExit((result) => {
725
+ // console.log(">>>>>>>>>>>>>>>>>>> exec onExit", result)
726
+ // })
727
727
  }
728
728
  } catch (e) {
729
729
  console.log("** Error", e)
@@ -747,7 +747,6 @@ class Shell {
747
747
  }
748
748
  }
749
749
  kill(message, force) {
750
- console.log("> KILL", { message, force })
751
750
 
752
751
  this.done = true
753
752
  this.ready = false
@@ -877,7 +876,6 @@ ${cleaned}
877
876
  let cached_msg = msg
878
877
  // todo: may need to handle cases when the command returns immediately with no output (example: 'which brew' returns immediately with no text if brew doesn't exist)
879
878
  setTimeout(() => {
880
- console.log({ cache, cleaned })
881
879
  if (cache === cleaned) {
882
880
  if (this.persistent) {
883
881
  if (this.cb) this.cb({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.2.198",
3
+ "version": "3.2.200",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -59,6 +59,7 @@
59
59
  "systeminformation": "^5.18.4",
60
60
  "uuid": "^9.0.0",
61
61
  "wait-on": "^7.2.0",
62
+ "which": "^5.0.0",
62
63
  "ws": "^8.13.0",
63
64
  "xterm-addon-fit": "^0.8.0",
64
65
  "xterm-addon-serialize": "^0.9.0",
package/server/index.js CHANGED
@@ -229,7 +229,7 @@ class Server {
229
229
  let error = null
230
230
  if (config && config.version) {
231
231
  let coerced = semver.coerce(config.version)
232
- console.log("version", { coerced, v: config.version })
232
+ // console.log("version", { coerced, v: config.version })
233
233
  if (semver.satisfies(coerced, this.kernel.schema)) {
234
234
  console.log("semver satisfied", config.version, this.kernel.schema)
235
235
  } else {
@@ -1761,7 +1761,7 @@ class Server {
1761
1761
  if (type === "conda") {
1762
1762
  return this.kernel.bin.installed.conda.has(name)
1763
1763
  } else if (type === "pip") {
1764
- return this.kernel.bin.installed.pip.has(name)
1764
+ return this.kernel.bin.installed.pip && this.kernel.bin.installed.pip.has(name)
1765
1765
  } else if (type === "brew") {
1766
1766
  return this.kernel.bin.installed.brew.has(name)
1767
1767
  } else {
@@ -2114,6 +2114,9 @@ class Server {
2114
2114
  console.log(`[TRY] reset ${p}`)
2115
2115
  await fse.remove(p)
2116
2116
  console.log(`[DONE] reset ${p}`)
2117
+ console.log("[TRY] Updating to the new version")
2118
+ this.kernel.store.set("version", this.version.pinokiod)
2119
+ console.log("[DONE] Updating to the new version")
2117
2120
  }
2118
2121
  }
2119
2122
 
@@ -3073,6 +3076,12 @@ class Server {
3073
3076
  await compressing.zip.compressDir(folder, zipPath)
3074
3077
  res.json({ success: true })
3075
3078
  }))
3079
+ this.app.get("/pinokio/info", ex(async (req, res) => {
3080
+ console.time("getInfo")
3081
+ await this.kernel.getInfo()
3082
+ console.timeEnd("getInfo")
3083
+ res.json(this.kernel.i || {})
3084
+ }))
3076
3085
  this.app.get("/pinokio/port", ex(async (req, res) => {
3077
3086
  let port = await this.kernel.port()
3078
3087
  res.json({ result: port })