Repository: JuliaPy/pyjulia

Issue:
Failure when setting optimize option
This is because pyjulia uses ArgumentsParser to parse --home & --sysimage, but it get the optimize value as an int instead of a string.

I'll submit a PR

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/JuliaPy/pyjulia/pull/481?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#481](https://codecov.io/gh/JuliaPy/pyjulia/pull/481?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (e097806) into [master](https://codecov.io/gh/JuliaPy/pyjulia/commit/56a739126d3fed0d24e548069ff216fea78fbe1b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (56a7391) will **decrease** coverage by `7.85%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##           master     #481      +/-   ##
==========================================
- Coverage   89.20%   81.34%   -7.86%     
==========================================
  Files          39       39              
  Lines        2315     2257      -58     
==========================================
- Hits         2065     1836     -229     
- Misses        250      421     +171     
```


| [Impacted Files](https://codecov.io/gh/JuliaPy/pyjulia/pull/481?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [src/julia/tests/test\_juliaoptions.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL3Rlc3RzL3Rlc3RfanVsaWFvcHRpb25zLnB5) | `100.00% <ø> (ø)` | |
| [src/julia/options.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL29wdGlvbnMucHk=) | `96.07% <100.00%> (-0.12%)` | :arrow_down: |
| [src/julia/tests/test\_options.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL3Rlc3RzL3Rlc3Rfb3B0aW9ucy5weQ==) | `100.00% <100.00%> (ø)` | |
| [src/julia/ipy/monkeypatch\_completer.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL2lweS9tb25rZXlwYXRjaF9jb21wbGV0ZXIucHk=) | `6.00% <0.00%> (-80.28%)` | :arrow_down: |
| [src/julia/ipy/monkeypatch\_interactiveshell.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL2lweS9tb25rZXlwYXRjaF9pbnRlcmFjdGl2ZXNoZWxsLnB5) | `12.50% <0.00%> (-70.84%)` | :arrow_down: |
| [src/julia/runtests.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL3J1bnRlc3RzLnB5) | `33.96% <0.00%> (-41.97%)` | :arrow_down: |
| [src/julia/tests/test\_python\_jl.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL3Rlc3RzL3Rlc3RfcHl0aG9uX2psLnB5) | `81.81% <0.00%> (-18.19%)` | :arrow_down: |
| [src/julia/tests/test\_find\_libpython.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL3Rlc3RzL3Rlc3RfZmluZF9saWJweXRob24ucHk=) | `83.33% <0.00%> (-16.67%)` | :arrow_down: |
| [src/julia/utils.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL3V0aWxzLnB5) | `80.00% <0.00%> (-13.34%)` | :arrow_down: |
| [src/julia/python\_jl.py](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2p1bGlhL3B5dGhvbl9qbC5weQ==) | `71.87% <0.00%> (-12.50%)` | :arrow_down: |
| ... and [24 more](https://codecov.io/gh/JuliaPy/pyjulia/pull/481/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/JuliaPy/pyjulia/pull/481?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/JuliaPy/pyjulia/pull/481?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Last update [56a7391...e097806](https://codecov.io/gh/JuliaPy/pyjulia/pull/481?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).

mkitti: We would need to get these tests passing 
mkitti: @MilesCranmer Clone the branch, get the tests to pass, and submit a new PR pinging me. Then I will merge it. 
dpinol: logs have expired. Can sb rerun the tests?
mkitti: Considering rebasing
dpinol: @mkitti done
mkitti: Hmm, that did not seem to fix testing. 
MilesCranmer: It seems unrelated to this PR - the issue seems to be because the CI is trying to download a pip package from an HTTP URL instead of HTTPS, and urllib no longer allows non-SSL requests:
```
      Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.27.tar.gz
```
I think that's why the Python 2.7 version works - since the old urllib hasn't deprecated non-SSL.
MilesCranmer: FYI @dpinol once #508 is merged this should work
dpinol: @MilesCranmer rebased. thanks

Patch:
diff --git a/src/julia/options.py b/src/julia/options.py
index 5b2728b..52d9364 100644
--- a/src/julia/options.py
+++ b/src/julia/options.py
@@ -134,7 +134,7 @@ class JuliaOptions(object):
     compile = Choices("compile", yes_no_etc("all", "min"))
     depwarn = Choices("depwarn", yes_no_etc("error"))
     warn_overwrite = Choices("warn_overwrite", yes_no_etc())
-    optimize = Choices("optimize", dict(zip(range(4), range(4))))
+    optimize = Choices("optimize", dict(zip(range(4), map(str, range(4)))))
     inline = Choices("inline", yes_no_etc())
     check_bounds = Choices("check_bounds", yes_no_etc())
 


Test patch:
diff --git a/src/julia/tests/test_juliaoptions.py b/src/julia/tests/test_juliaoptions.py
index 931438f..b793e73 100644
--- a/src/julia/tests/test_juliaoptions.py
+++ b/src/julia/tests/test_juliaoptions.py
@@ -12,6 +12,7 @@ from julia.core import JuliaOptions
     (dict(depwarn="error"), ["--depwarn", "error"]),
     (dict(sysimage="PATH"), ["--sysimage", "PATH"]),
     (dict(bindir="PATH"), ["--home", "PATH"]),
+    (dict(optimize=3), ["--optimize", "3"]),
 ])
 # fmt: on
 def test_as_args(kwargs, args):
diff --git a/src/julia/tests/test_options.py b/src/julia/tests/test_options.py
index c11e4bd..1ab9cb8 100644
--- a/src/julia/tests/test_options.py
+++ b/src/julia/tests/test_options.py
@@ -1,4 +1,4 @@
-from julia.options import JuliaOptions, options_docs
+from julia.options import JuliaOptions, options_docs, parse_jl_options
 
 
 def parse_options_docs(docs):
@@ -23,3 +23,11 @@ def test_options_docs():
         odef = optdefs.pop(desc.name)
         assert odef["domain"] == desc._domain()
     assert not optdefs
+
+
+def test_parse_jl_options():
+    opts = parse_jl_options(
+        ["--home", "/home", "--sysimage", "/sys/image", "--optimize", "3"]
+    )
+    assert opts.home == "/home"
+    assert opts.sysimage == "/sys/image"