JavaFXpert / vqe-playground

Playground for gaining intuition about Variational Quantum Eigensolver
Other
16 stars 7 forks source link

moving files into vqe_playgroud module and introducing vqe-playground entry point #2

Closed haraldschilly closed 5 years ago

haraldschilly commented 5 years ago

I've started to work on packaging this. I'm not an expert with that, but so far so good. All the import paths needs to be fixed, and I only looked into a couple of them.

The main new detail here is the entry point for a vqe-playground script. This is how I develop this:

  1. in the root dir of this, I'm running that to install it locally in my home directory (cocalc project)
~/vqe-playground$ pip3 install --user -U ./
Processing /home/user/vqe-playground
Building wheels for collected packages: vqe-playground-006
  Building wheel for vqe-playground-006 (setup.py) ... done
  Stored in directory: /home/user/.cache/pip/wheels/6f/cd/44/a97fc99db8de61f1cad24259ab3b02193fd2fba75df3dc4f08
Successfully built vqe-playground-006
Installing collected packages: vqe-playground-006
  Found existing installation: vqe-playground-006 0.0.1
    Uninstalling vqe-playground-006-0.0.1:
      Successfully uninstalled vqe-playground-006-0.0.1
Successfully installed vqe-playground-006-0.0.1
  1. then this is available:
~/vqe-playground$ which vqe-playground 
/home/user/.local/bin/vqe-playground
  1. I can attempt to launch it from an x11 environment, but it fails with import problems:
~$ vqe-playground
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
/usr/local/lib/python3.6/dist-packages/marshmallow/schema.py:364: ChangedInMarshmallow3Warning: strict=False is not recommended. In marshmallow 3.0, schemas will always be strict. See https://marshmallow.readthedocs.io/en/latest/upgrading.html#schemas-are-always-strict
  ChangedInMarshmallow3Warning
Traceback (most recent call last):
  File "/home/user/.local/bin/vqe-playground", line 6, in <module>
    from vqe_playground.command_line import main
  File "/home/user/.local/lib/python3.6/site-packages/vqe_playground/command_line.py", line 1, in <module>
    from .vqe_main import VQEPlayground
  File "/home/user/.local/lib/python3.6/site-packages/vqe_playground/vqe_main.py", line 44, in <module>
    from .viz.expectation_grid import ExpectationGrid
  File "/home/user/.local/lib/python3.6/site-packages/vqe_playground/viz/__init__.py", line 17, in <module>
    from .circuit_diagram import CircuitDiagram
  File "/home/user/.local/lib/python3.6/site-packages/vqe_playground/viz/circuit_diagram.py", line 19, in <module>
    from utils.resources import load_image
ModuleNotFoundError: No module named 'utils'

The solution here would be to use a relative import, i.e. from .utils.resources import load_image ... or to be absolute, i.e. from vqe_playground.utils.resources import load_image ... depending on where the files are relative to each other. Or maybe there is a more clever way to do this, I don't know.

JavaFXpert commented 5 years ago

Thanks Harald. I’ll take a look and try to work through the issue.

Regards, James (Jim) Weaver

On Apr 18, 2019, at 6:33 AM, Harald Schilly notifications@github.com wrote:

I've started to work on packaging this. I'm not an expert with that, but so far so good. All the import paths needs to be fixed, and I only looked into a couple of them.

The main new detail here is the entry point for a vqe-playground script. This is how I develop this:

in the root dir of this, I'm running that to install it locally in my home directory (cocalc project) ~/vqe-playground$ pip3 install --user -U ./ Processing /home/user/vqe-playground Building wheels for collected packages: vqe-playground-006 Building wheel for vqe-playground-006 (setup.py) ... done Stored in directory: /home/user/.cache/pip/wheels/6f/cd/44/a97fc99db8de61f1cad24259ab3b02193fd2fba75df3dc4f08 Successfully built vqe-playground-006 Installing collected packages: vqe-playground-006 Found existing installation: vqe-playground-006 0.0.1 Uninstalling vqe-playground-006-0.0.1: Successfully uninstalled vqe-playground-006-0.0.1 Successfully installed vqe-playground-006-0.0.1 then this is available: ~/vqe-playground$ which vqe-playground /home/user/.local/bin/vqe-playground I can attempt to launch it from an x11 environment, but it fails with import problems: ~$ vqe-playground pygame 1.9.4 Hello from the pygame community. https://www.pygame.org/contribute.html /usr/local/lib/python3.6/dist-packages/marshmallow/schema.py:364: ChangedInMarshmallow3Warning: strict=False is not recommended. In marshmallow 3.0, schemas will always be strict. See https://marshmallow.readthedocs.io/en/latest/upgrading.html#schemas-are-always-strict ChangedInMarshmallow3Warning Traceback (most recent call last): File "/home/user/.local/bin/vqe-playground", line 6, in from vqe_playground.command_line import main File "/home/user/.local/lib/python3.6/site-packages/vqe_playground/command_line.py", line 1, in from .vqe_main import VQEPlayground File "/home/user/.local/lib/python3.6/site-packages/vqe_playground/vqe_main.py", line 44, in from .viz.expectation_grid import ExpectationGrid File "/home/user/.local/lib/python3.6/site-packages/vqe_playground/viz/init.py", line 17, in from .circuit_diagram import CircuitDiagram File "/home/user/.local/lib/python3.6/site-packages/vqe_playground/viz/circuit_diagram.py", line 19, in from utils.resources import load_image ModuleNotFoundError: No module named 'utils' The solution here would be to use a relative import, i.e. from .utils.resources import load_image ... or to be absolute, i.e. from vqe_playground.utils.resources import load_image ... depending on where the files are relative to each other. Or maybe there is a more clever way to do this, I don't know.

You can view, comment on, or merge this pull request online at:

https://github.com/JavaFXpert/vqe-playground/pull/2

Commit Summary

moving files into vqe_playgroud module and introducing vqe-playground entry point File Changes

D main.py (21) M setup.py (9) R vqe_playground/init.py (0) A vqe_playground/command_line.py (5) R vqe_playground/containers/init.py (0) R vqe_playground/containers/hbox.py (0) R vqe_playground/containers/vbox.py (0) R vqe_playground/controls/init.py (0) R vqe_playground/controls/adjacency_matrix.py (8) R vqe_playground/controls/button.py (0) R vqe_playground/controls/circuit_grid.py (10) R vqe_playground/controls/matrix_label.py (0) R vqe_playground/controls/number_picker.py (0) R vqe_playground/data/bell_histogram.png (0) R vqe_playground/model/init.py (0) R vqe_playground/model/circuit_grid_model.py (2) R vqe_playground/model/circuit_node_types.py (0) R vqe_playground/utils/init.py (0) R vqe_playground/utils/colors.py (0) R vqe_playground/utils/data/bell_circuit.png (0) R vqe_playground/utils/data/bell_histogram.png (0) R vqe_playground/utils/data/bell_qsphere.png (0) R vqe_playground/utils/data/gate_images/ctrl_gate.png (0) R vqe_playground/utils/data/gate_images/ctrl_gate_bottom_wire.png (0) R vqe_playground/utils/data/gate_images/ctrl_gate_top_wire.png (0) R vqe_playground/utils/data/gate_images/h_gate.png (0) R vqe_playground/utils/data/gate_images/iden_gate.png (0) R vqe_playground/utils/data/gate_images/not_gate.png (0) R vqe_playground/utils/data/gate_images/not_gate_above_ctrl.png (0) R vqe_playground/utils/data/gate_images/not_gate_below_ctrl.png (0) R vqe_playground/utils/data/gate_images/rx_gate.png (0) R vqe_playground/utils/data/gate_images/ry_gate.png (0) R vqe_playground/utils/data/gate_images/rz_gate.png (0) R vqe_playground/utils/data/gate_images/s_gate.png (0) R vqe_playground/utils/data/gate_images/sdg_gate.png (0) R vqe_playground/utils/data/gate_images/swap_gate.png (0) R vqe_playground/utils/data/gate_images/t_gate.png (0) R vqe_playground/utils/data/gate_images/tdg_gate.png (0) R vqe_playground/utils/data/gate_images/trace_gate.png (0) R vqe_playground/utils/data/gate_images/x_gate.png (0) R vqe_playground/utils/data/gate_images/y_gate.png (0) R vqe_playground/utils/data/gate_images/z_gate.png (0) R vqe_playground/utils/data/images/circuit-grid-cursor-60px.png (0) R vqe_playground/utils/data/images/circuit-grid-cursor.png (0) R vqe_playground/utils/data/mel_circ.png (0) R vqe_playground/utils/fonts.py (0) R vqe_playground/utils/gamepad.py (0) R vqe_playground/utils/labels.py (0) R vqe_playground/utils/navigation.py (0) R vqe_playground/utils/resources.py (0) R vqe_playground/utils/states.py (0) R vqe_playground/viz/init.py (0) R vqe_playground/viz/circuit_diagram.py (0) R vqe_playground/viz/expectation_grid.py (0) R vqe_playground/viz/measurements_histogram.py (0) R vqe_playground/viz/network_graph.py (0) R vqe_playground/viz/qsphere.py (0) R vqe_playground/vqe_main.py (18) D vqe_playground_pkg/command_line.py (6) Patch Links:

https://github.com/JavaFXpert/vqe-playground/pull/2.patch https://github.com/JavaFXpert/vqe-playground/pull/2.diff — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.