Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test support in node 14 #33

Merged
merged 4 commits into from
Nov 24, 2021
Merged

test support in node 14 #33

merged 4 commits into from
Nov 24, 2021

Conversation

rom1504
Copy link
Collaborator

@rom1504 rom1504 commented Nov 23, 2021

#32

@mattseddon
Copy link

FYI If I change the version in here to 14 and run with v14.17.0 the tests do pass. Happy to fork and open a PR if that would help.

~/PP/JSPyBridge master !1 ❯ node -v                                                                   0.03583s  example-dvc-experiments  3.0.0 15:25:12
v14.17.1
~/PP/JSPyBridge master !1 ❯ npm test                                                                  0.03784s  example-dvc-experiments  3.0.0 15:25:22

> pythonia@0.2.12 pretest
> pip3 install -e . && python3 -m javascript --install chalk

Obtaining file:///Users/mattseddon/PP/JSPyBridge
  Preparing metadata (setup.py) ... done
Installing collected packages: javascript
  Attempting uninstall: javascript
    Found existing installation: javascript 1!0.2.12
    Uninstalling javascript-1!0.2.12:
      Successfully uninstalled javascript-1!0.2.12
  Running setup.py develop for javascript
Successfully installed javascript-1!0.2.12

up to date, audited 438 packages in 1s

81 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> pythonia@0.2.12 test
> mocha

hello world :)


"Hello world!\n5 [ [], 5, 6, 7, 8, { a: 3 } ] []\ncallback from JS (Some Python object) 3\nwrapped fn 3\n6\nwow\n123!\nHello  world\ni []\ni 5\ni 6\ni 7\ni 8\ni { a: 3 }\nCallback called with ('It works !',)\nHandler caled [Function (anonymous)] 4 {'a': {'y': 5}}\nHey, I'm only called once !\nHandler caled [Function (anonymous)] 5 {'a': {'y': 6}}\nHandler caled [Function (anonymous)] 6 {'a': {'y': 7}}\nHandler caled [Function (anonymous)] 7 {'a': {'y': 8}}\nDemo array and object [ 1, 5, 3 ] { '1': 5, '2': (Some Python object), a: 'ay', b: 'be', c: 'ce' }\nOK, captured error\nArray [1, 5, 3]\n2\nMy var {'var': 5, 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9}\nOK, we can now exit\n" 

  ✔ runs test (1515ms)
Hello world!
i []
i 5
i 6
i 7
i 8
i { a: 3 }
callback from JS (Some Python object) 3
Callback called with It works !
Demo array and object [ 1, 5, 3 ] { '1': 5, '2': (Some Python object), a: 'ay', b: 'be', c: 'ce' }
OK, captured error
A [1, 5, 3]
Array [1, 5, 3]
Handler caled [Function (anonymous)] 4 {'a': {'y': 5}}
Hey, I'm only called once !
Handler caled [Function (anonymous)] 5 {'a': {'y': 6}}
Handler caled [Function (anonymous)] 6 {'a': {'y': 7}}
Handler caled [Function (anonymous)] 7 {'a': {'y': 8}}
wrapped fn 3
2
My var {'var': 5, 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9}
100000
  ✔ runs general test (1036ms)
ok <function add_inverse at 0x101bf6f70>
complex (-1+0j)
real & complex -1 0
FABC - this will fail 
[You must use await when calling a Python API]

  ✔ does function calls
CB [AsyncFunction (anonymous)] <Bridge.MyClas object at 0x101bfe7c0> 3 7
  ✔ declares classes
<demo.py.DemoClass object at 0x101bfea30>
  ✔ consumes classes
** Error in exception handler ** Error: ENOENT: no such file or directory, open 'internal/process/task_queues.js'
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at processJSStacktrace (/Users/mattseddon/PP/JSPyBridge/src/pythonia/errors.js:68:25)
    at Object.getErrorMessage (/Users/mattseddon/PP/JSPyBridge/src/pythonia/errors.js:83:24)
    at new PythonException (/Users/mattseddon/PP/JSPyBridge/src/pythonia/Bridge.js:20:25)
    at Bridge.call (/Users/mattseddon/PP/JSPyBridge/src/pythonia/Bridge.js:250:37)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Context.<anonymous> (file:///Users/mattseddon/PP/JSPyBridge/test/pythonia.test.mjs:49:5) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'internal/process/task_queues.js'
}
** JavaScript Stacktrace **
    at Bridge.call (/Users/mattseddon/PP/JSPyBridge/src/pythonia/Bridge.js:250:37)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Context.<anonymous> (file:///Users/mattseddon/PP/JSPyBridge/test/pythonia.test.mjs:49:5)
** Python Stacktrace **
Traceback (most recent call last):
  File "/Users/mattseddon/PP/JSPyBridge/src/pythonia/Bridge.py", line 365, in onMessage
    return getattr(self, action)(r, ffid, key, args)
  File "/Users/mattseddon/PP/JSPyBridge/src/pythonia/Bridge.py", line 338, in pcall
    self.call(r, ffid, key, pargs, kwargs or {})
  File "/Users/mattseddon/PP/JSPyBridge/src/pythonia/Bridge.py", line 198, in call
    v = v(*args, **kwargs)
  File "/Users/mattseddon/PP/JSPyBridge/test/pythonia/demo.py", line 7, in throw
    raise Exception("hey I crashed!")
Exception: hey I crashed!

OK!
  ✔ catches errors
Fn call 1 2 3 {'extra': 77, 'xx': 0.9269057816868453}
  ✔ calls functions with special args
3 + 3 (6+5j)
  ✔ can add Python numbers
[1, 2, 4]
{'a': 'wow', 'b': 'meow'}
  ✔ can set variables
[ 1, 2, 4 ] object
  ✔ can return primitive values
1
2
4
  ✔ can iterate asynchronously
  ✔ can iterate from Python
9223372036854776000
  ✔ can recieve big numbers

  13 passing (3s)

~/PP/JSPyBridge master !1 ❯                                                                           7.16226s  example-dvc-experiments  3.0.0 15:25:32

@rom1504
Copy link
Collaborator Author

rom1504 commented Nov 24, 2021

Ok i just added that in this PR, let's see if that's enough

What do you think @extremeheat ? Any drawback to supporting node >= 14 ?

@rom1504
Copy link
Collaborator Author

rom1504 commented Nov 24, 2021

Still getting Error: Cannot find module 'yargs-parser' after that change @mattseddon

If you have time to investigate, feel free to suggest further changes

@extremeheat
Copy link
Owner

extremeheat commented Nov 24, 2021

Did some debugging, seems like the issue was the in-place python package install for the python test. Should be OK now.

I believe the main issue with node 14 was with the javascript pip package where the event emitter handling code changed in node 15/16 causing the behavior on the Python side to be different. It was fixed with a patch here. I don't think the issue is present on the pythonia package as we don't do event emitter handling there, so yeah doesn't seem like there's any other blocking issue for node 16.

@rom1504
Copy link
Collaborator Author

rom1504 commented Nov 24, 2021

Ok, let's merge it then ?

@extremeheat
Copy link
Owner

Lgtm

@rom1504 rom1504 merged commit 58a4ce6 into master Nov 24, 2021
@rom1504 rom1504 deleted the node_14 branch November 24, 2021 09:02
@rom1504
Copy link
Collaborator Author

rom1504 commented Nov 24, 2021

Ok, i guess we'll need a new release too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants