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

How to get the clicked axes in the batched_axes? #271

Open
zjcs opened this issue Aug 21, 2024 · 12 comments
Open

How to get the clicked axes in the batched_axes? #271

zjcs opened this issue Aug 21, 2024 · 12 comments

Comments

@zjcs
Copy link

zjcs commented Aug 21, 2024

According to the recommand in the viser, add_batched_axes is a good choice to add multiple axes. These axes act as the children scene node, and the batched_axes act as a single parent scene node.
However, when I use it and add a event listener of it, how can I get the selected child axes, an axes in the add_batched_axes? It seems that the event is listening the parent scene node, and no selected child axes index return.

@brentyi
Copy link
Collaborator

brentyi commented Aug 21, 2024

Hi @zjcs! Can you see if #272 implements what you're looking for?

@zjcs
Copy link
Author

zjcs commented Aug 22, 2024

Thank you very much. I read the code, I think it is what I want, But I cannot test it, since when I run this branch, the code fail during the "Install prebuilt node". I think it is due to my internet connection, I am trying to solve it...
Do you have plan to merge it into the main branch?

@zjcs
Copy link
Author

zjcs commented Aug 22, 2024

B.T.W, I found the error during "Install prebuilt node" only happens on pip install ., while success from the pre-built wheel. Do you have any suggestion?

@brentyi
Copy link
Collaborator

brentyi commented Aug 22, 2024

Unfortunately I'm juggling a few other things right now so merge/release might take a little while. There are also some details in that PR (like the hover outline effect) that I want to revisit.

B.T.W, I found the error during "Install prebuilt node" only happens on pip install ., while success from the pre-built wheel. Do you have any suggestion?

This is because we include a pre-built version of the client in PyPI releases, which isn't present when you install from source. I'm not aware of any issues in the automatic client build code, so if you're able to narrow down the problem I'd be interested in more information!

One other option you can take is to build manually, this involves cd'ing into src/viser/client, running yarn install, and then yarn build.

@zjcs
Copy link
Author

zjcs commented Aug 22, 2024

Can you provide more information about the viser install and client install step? When I try it, it seems a long time cost to download and compile.
I have three questions:
(1) install order: a. pip install path-to-viser && cd path-to-viser/src/viser/client && yarn install && yarn build, b. cd path-to-viser/src/viser/client && yarn install && yarn build && pip install path-to-viser. Which is the right install order?
(2) launch the viewer: after I install viser and client, can I run the python-code directly as usual and the viewer url will be
accessable as usual, or other addtional command like yarn start?
(3) I find the Client development in viser doc is a little different, viser doc suggest to run yarn install only to install client and yarn start to launch the viewer, and need to install prettier?
Since I am still blocked during the install step, is there any other unexpected things to do?

@zjcs
Copy link
Author

zjcs commented Aug 22, 2024

Can you provide more information about the viser install and client install step? When I try it, it seems a long time cost to download and compile. I have three questions: (1) install order: a. pip install path-to-viser && cd path-to-viser/src/viser/client && yarn install && yarn build, b. cd path-to-viser/src/viser/client && yarn install && yarn build && pip install path-to-viser. Which is the right install order? (2) launch the viewer: after I install viser and client, can I run the python-code directly as usual and the viewer url will be accessable as usual, or other addtional command like yarn start? (3) I find the Client development in viser doc is a little different, viser doc suggest to run yarn install only to install client and yarn start to launch the viewer, and need to install prettier? Since I am still blocked during the install step, is there any other unexpected things to do?

After try sometimes, I finally success to install viser from source code:

  1. pip install .
  2. cd src/viser/client && yarn install && yarn build
  3. cp -r src/viser/client/build $CONDA/envs/$PYENV/lib/python3.10/site-packages/viser/client/

yarn install will download many files in the folder src/viser/client/node_modules and about several minutes cost. But if install client first (step 2.) and install vieser (step 1.), it will waste many times during install viser in the stage Building wheel for viser (pyproject.toml) ..., and these downloaded file is not used in python-packages, only build folder is used. Another problem of this wrong install order is, these download files in node_modules will copied to the folder $VISER-SOURCE-CODE/build, it's better to manully delete it during the following pip install.

I think the step 3 is a little confused and complex...

@brentyi
Copy link
Collaborator

brentyi commented Aug 22, 2024

Thanks for the info + sorry about the difficulty!

Usually I just use an editable install pip install -e .. This would probably be simpler because then the ordering doesn't matter, you don't need to worry about the copy step, it doesn't need to build wheels, etc.

@brentyi
Copy link
Collaborator

brentyi commented Aug 22, 2024

Also @zjcs can I ask what OS you're on? Do you think this is related to your Install prebuilt node problems?

If you're in China is there any chance it's network related?

@zjcs
Copy link
Author

zjcs commented Aug 23, 2024

Linux OS. It is due to the company network firewall, so Install prebuilt node is failed to download, and I need to build viser from source code.
The main problem during pip install viser from source code is yarn install will download many files, and the following pip install . or pip install -e . will spend many time to copy these unnecessary file to the target folder. Since this is the first time to install viser from source code and I am not clear about the total process, I kill the install command during a long time wait. So I think it's better to remove these download files under src/viser/client/node_modules after the yarn build, to avoid the long time cost during copy these file to target folder.

@zjcs
Copy link
Author

zjcs commented Aug 23, 2024

d probably be simpler because then the ordering d

I think these build result of yarn build under the folder src/viser/client/build has beed copied to the folder build/lib/viser/client when you use pip install -e .. And no files or less files under the folder src/viser/client/node_modules, while directly yarn install will download many files under this folder. But I find this folder is only two files if I use pip install viser to install viser from the wheel. The main difference of time cost is spend on copying src/viser/client/node_modules.

@brentyi
Copy link
Collaborator

brentyi commented Aug 23, 2024

Thanks @zjcs!

The reason the PyPI install is smaller/faster is because we only include the built client in the released package:

- name: Only bundle client build for PyPI release
run: |
# This sed command finds the line that immediately follows
# [tool.setuptools.package-data], then replaces instances of
# `client/**/*` with `client/build/**/*`.
sed -i=bak '/\[tool\.setuptools\.package-data\]/{n;s/"client\/\*\*\/\*"/"client\/build\/\*\*\/\*"/g;}' pyproject.toml
# This sed commands removes `, "client/**/.*"` from the package-data.
sed -i=bak '/\[tool\.setuptools\.package-data\]/{n;s/, "client\/\*\*\/\.\*"//g;}' pyproject.toml

Also to clarify, my expectation if you do an editable install from pip install -e . is that there should be no build/lib directory at all. So unlike pip install ., there should be no time spent copying.

I did just push a commit that will exclude node_modules from the wheel if you run pip install . though, so hopefully that experience will be better for folks in the future! If you want to try it, I would recommend deleting the viser/build and src/viser.egg-info directories first.

@zjcs
Copy link
Author

zjcs commented Aug 24, 2024

Sorry to reply late.

I re-install viser again today. Yeah, you are right, pip install -e . will not create $VISER-SOURCE-CODE/build folder since the editable install while this folder is only created when pip install ..

Now, pip install . will be very fast using the latest main branch. And it will copy the node build result under src/viser/client if you build client from source code, the auto pre-build node download will not happen. It will be useful when the network connection is disabled.

Thanks very much for your timely help.

One more thing, I want to clarify the steps of pip install from source code:

  1. cd src/viser/client && yarn install && yarn build
  2. cd ../../../ && pip install .

Finally, the node build result under the folder src/viser/client/build will be copied to the py-envs site-packages/viser/client/.

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

No branches or pull requests

2 participants