Skip to content

Conversation

@tkf
Copy link
Member

@tkf tkf commented Aug 1, 2018

It simplifies local development and CI setup:

  • Cross-version testing can be done with a single command locally.
  • We can make sure that same set of Python packages are installed locally and in CI clouds.
  • tox and pytest outputs are much nicer and helpful (but there are options for verbose outputs)

It's WIP since I'm not sure Travis and AppVeyor setups are correct yet.

@tkf tkf changed the title WIP Use tox and pytest WIP / Suggestion: Use tox and pytest Aug 1, 2018
@tkf
Copy link
Member Author

tkf commented Aug 1, 2018

So it looks like it is not testing "cache reuse" mode at the moment. Let's see if I can find a nice way to fix this...

@tkf tkf force-pushed the tox branch 8 times, most recently from 2f30486 to d767c6d Compare August 5, 2018 03:40
@tkf tkf force-pushed the tox branch 2 times, most recently from 15b9ca2 to d1a386c Compare August 5, 2018 04:52
so that it's runnable in Windows as well.
@tkf
Copy link
Member Author

tkf commented Aug 5, 2018

OK. I think it's ready for review. (ping @stevengj @rdeits)

To support "shared-cache mode", I added a script julia/with_rebuilt.py to build PyCall.jl with the Python interpreter used for testing and build back to the original configuration. This is documented in README too: https://github.com/tkf/pyjulia/tree/tox#testing

Some summaries for misc details:

  • I switched to testing against nightly to 0.7-rc to wait for PyCall.jl etc to get ready for 1.0. This required a slight improvement of ci/install-julia.sh.
  • I added tests for IPython magics and fixed some bugs in the module importer. I pulled Fix exception printing #151 and added tests for it too.
  • In AppVeyor, tests for Python 2 and 3 are run in the same job. Considering low-throughput of AppVeyor and overhead of downloading and installing Julia, I think it's a reasonable compromise. But we can always separate them in different jobs by adding TOXENV for each job.

Some details for cross-version test in Windows with Python 2.7

Note that cross-version test in Windows with Python 2 fails and the failure is ignored at the moment. But it turned out our previous CI setting didn't actually test cross-version capability. The problematic part was here:

- ps: if (Test-Path Env:\CROSS_VERSION_PATH) { Invoke-Expression "$env:CROSS_VERSION_PATH -m unittest discover" }

There were two issues: (1) CROSS_VERSION_PATH was not actually path to the executable. It perhaps meant to be $env:CROSS_VERSION_PATH\\python -m unittest discover or something. (2) Invoke-Expression does not fail even when the invoked command fails. So the tests were passing even though we had an error: https://ci.appveyor.com/project/Keno/pyjulia/build/1.0.107/job/8rhimj9mkxins0yn#L101

I think the way Python 2 cross-version test fails needs attention from PyCall.jl/pyjulia experts. The error happens when evaluating using PyCall and it says:

LLVM ERROR: Program used external function 'trunc' which could not be resolved!

(see, e.g., https://ci.appveyor.com/project/Keno/pyjulia/build/1.0.134/job/0l9qvw8dgp1636s4#L158)

I remember having the same issue when I helped setting up CI for diffeqpy SciML/diffeqpy#25 It used the released version of pyjulia so it's possible that this problem has been there for some times.

@tkf tkf requested review from rdeits and stevengj August 5, 2018 20:01
@tkf tkf changed the title WIP / Suggestion: Use tox and pytest Suggestion: Use tox and pytest Aug 5, 2018
if fullname.startswith("julia."):
pypath = os.path.join(os.path.dirname(__file__),
"{}.py".format(fullname[len("julia."):]))
if os.path.isfile(pypath):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to fallback to standard Python importer in this case to import Python submodules (e.g., julia/magic.py).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, this has to be improved if/when we have python subpackages.

# Flush, otherwise the Julia startup will keep stdout buffered
sys.stdout.flush()
self.julia = Julia(init_julia=True)
self._julia = Julia(init_julia=True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous self.julia = ... was shadowing the method julia. It was fine because the method was actually not called directly in IPython magic system. But it's handy to not shadow for testing.


def is_same_path(a, b):
a = os.path.normpath(os.path.normcase(a))
b = os.path.normpath(os.path.normcase(b))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.path.normcase is required in Windows since Python interpreter path reported by Julia and Python have different cases:

pyprogramname = C:\projects\pyjulia\.tox\py\Scripts\python.EXE
sys.executable = C:\projects\pyjulia\.tox\py\Scripts\python.exe

https://ci.appveyor.com/project/Keno/pyjulia/build/1.0.134/job/s2kvagang1g9e0hu#L201

@@ -0,0 +1 @@
@C:\Python35-x64\python.exe %*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made ci/appveyor/win*/python*.bat files, following the recommendation here:

https://tox.readthedocs.io/en/latest/developers.html#id2
tox-dev/tox#114 (comment)

Note that adding CI support for Python 3.6 and 3.7 requires adding more of those files.

@tkf tkf mentioned this pull request Aug 5, 2018
@tkf
Copy link
Member Author

tkf commented Aug 16, 2018

@stevengj Can I merge my PR without a review? Some OSS projects have the policy that you don't merge your own PR. Not sure how it works in JuliaPy. I wonder something like "if my PR does not induce major or minor version bumps, it's likely to be OK to pull it myself" would work. I wouldn't still pull it myself if it's a huge change in the entire codebase like a drastic refactoring.

@tkf tkf mentioned this pull request Aug 17, 2018
@stevengj
Copy link
Member

LGTM.

@stevengj stevengj merged commit 25ab71c into JuliaPy:master Aug 17, 2018
@tkf tkf mentioned this pull request Aug 17, 2018
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.

3 participants