[x3d-public] Fwd: Next, in Python news...

John Carlson yottzumm at gmail.com
Tue Aug 24 23:30:51 PDT 2021


Don, please try your tests in a python virtual environment. Thanks!

I'm up-to-date, I'm almost positively sure. I just converted the X3D 
archives (about 1-2 hours ago) to python using X3dToPython.xslt, and 
there were many, problems with Protos.  I can rerun with logging 
enabled, if you want to look at the logs. (but you don't seem inclined, 
so I'll only do it on request).  I ran inside X3DJSONLD, and got a ton 
of problems with Protos. I have 66 files with Protos out of 160 X3D 
files.  So it's not some random fluke!   51 of the python files had the 
issue.

You can look through your logs by searching for isinstance:

```    if not ProtoBody is None and not 
isinstance(ProtoBody,(ProtoBody,ProtoInstance)):
TypeError: isinstance() arg 2 must be a type or tuple of types

```

Those lines basically tells it all.  The ProtoBody parameter is being 
used as a type, AFAICT

Here's a few you may have in the 3D archives:

Figure31_9SpinGroupPrototype.x3d

AllenDuttonProtoInstances.x3d
AllenStandShootRifleM24.x3d

HelloWorldProgramOutput.x3d

What I have discovered, is, I have to enable a virtual environment in 
python to get the errors for these python program. Otherwise, I get 
other errors.  These files haven't been modified since Aug 16, but 
X3dToPython.xslt changed on Jun 10.  I don't know why enabling the 
virtual environment make a difference.

This is the script I ran, pretty much. I saw many Exceptions thrown 
around ProtoBody, ProtoDeclare:

=========================================================================

!/bin/bash

# Run the Test Suite

# accepts files with .x3d extension
export PROCESSORS=${PROCESSORS-8}

. ./classpath

echo translating to python
(find /c/x3d-code/www.web3d.org/x3d/content/examples -type f -name 
'*.x3d' | grep -v intermediate | grep -v "\.new") | xargs -P $PROCESSORS 
java net.coderextreme.RunSaxon ---overwrite ---silent 
--../lib/stylesheets/X3dToPython.xslt -py ---../python/net/x3djsonld/data/
echo running python
pushd ../python/net/x3djsonld/data
export PYTHONPATH=`pwd`
find c -name '*.py' | xargs -L 1 -P $PROCESSORS python3
popd

=====================================================================================

I saw no other types of errors in my sampling.  Perhaps you could point 
out a python example, or send me an example that works with Protos, and 
I could test it on my system?

I actually have 3 different rubik's examples.   So it would take some 
investigating and remembering if I sent the same one again. I'm fairly 
sure I chose the simplest one I have. abox.x3d and x3domflowers.x3d are 
others.  Still the overwhelming report is from the archive, but perhaps 
I need a Savage update? Nope.

Here to help the blind walk and the lame see!  In the 5th dimension of 
course!

John



On 8/24/21 10:41 PM, Brutzman, Donald (Don) (CIV) wrote:
>
> John, we have a lot of simple prototypes and prototypes with embedded 
> Script nodes in the archives that have all tested OK.
>
> If your example is that Rubiks’s cube with nested prototypes, that is 
> harder.  We believe the spec is OK but that feature is only 
> occasionally demonstrated as working.  Any model with nested 
> prototypes (ProtoDeclare within ProtoDeclare) can be easily refactored 
> by putting all of the ProtoDeclare blocks first.  Similarly it makes 
> sense to test individual ProtoInstance nodes without feeding them 
> nested ProtoInstance fields.
>
> Looking at existing examples is also good because they have passed 
> through validation.  Step by step.
>
>   * https://www.web3d.org/x3d/content/examples/X3dResources.html#Examples
>     <https://www.web3d.org/x3d/content/examples/X3dResources.html#Examples>
>
> Once again sorry I can’t pursue “deep dive” excursions at this time.  
> Am working on (a) X3D architecture Mantis editorial issues, (b) DIS 
> protocol implementation open-dis7-java, upgraded DIS support in Xj3D, 
> and just tonight got X3D-Edit building despite issues with a very old 
> laptop. Step  by step.
>
> *From:* x3d-public <x3d-public-bounces at web3d.org> *On Behalf Of *John 
> Carlson
> *Sent:* Tuesday, August 24, 2021 7:48 PM
> *To:* Joseph D Williams <joedwil at earthlink.net>
> *Cc:* X3D Graphics public mailing list <x3d-public at web3d.org>
> *Subject:* Re: [x3d-public] Fwd: Next, in Python news...
>
> Yes, you need to ‘’’pip install x3d’’’
>
> before running the provided script in previous message.   See link 
> previously posted by Joe.
>
> Thanks for confirmation of received message.
>
> The header is the top of the file. If you don’t want to run my code, 
> convert your own proto xml to python using X3dToPython.xslt.   I don’t 
> have a JSON converter for this test.
>
> The main purpose is to get proper implementation of Protos in pure 
> python.   I’m guessing it may be a wider problem with x3d.py, because 
> when I patched Protos in my version, there were further issues.   So 
> simply patching Protos won’t fix all the issues. A full roundtrip XML 
> -> python -> XML needs to be done for the archive.
>
> I’ve freed up some time to work on python, and I plan to start work on 
> a test suite soon. It would be good to get past my initial issues with 
> the package.   I can reattempt to modify the x3d package generator, 
> but that doesn’t mean my patches will be available when I am done.   
>  It still needs to go through official channels.
>
> If you’re fed up with stylesheets, I can offer a solution, but it’s 
> not as elegant or pythonic and uses Java.   As far as I can tell, XSLT 
> is the declarative transformer of choice for XML.
>
> The main thing I think needs to be done is handle cases where 
> parameters and classes have the same case sensitive name.
>
> If people want to contribute to x3d.py project, now’s your chance.   
> I’m fairly sure the python binding needs to be standardized.
>
> I know pretty much everyone has been covidized.
>
> After spinning up python, I’ll return to C++ if there’s enough code 
> separated from the standard.
>
> John
>
> On Tue, Aug 24, 2021 at 8:55 PM Joseph D Williams 
> <joedwil at earthlink.net <mailto:joedwil at earthlink.net>> wrote:
>
>     # Now available: developmental python x3d.py package on PyPi for
>     import.
>
>     # This approach greatly simplifies Python X3D deployment and use.
>
>     # https://pypi.org/project/x3d
>     <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpypi.org%2Fproject%2Fx3d&data=04%7C01%7Cbrutzman%40nps.edu%7C72693df0fce44ec3ba3408d96772eba5%7C6d936231a51740ea9199f7578963378e%7C0%7C0%7C637654565985912019%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Sw68kSJJKNZaBcGFk4Up3toP5CkFxSgiUQASR49Cfos%3D&reserved=0>
>
>     The text got here as attachment
>
>     Joe
>
>     *From: *John Carlson <mailto:yottzumm at gmail.com>
>     *Sent: *Tuesday, August 24, 2021 3:00 PM
>     *To: *Don Brutzman <mailto:brutzman at nps.edu>; X3D Graphics public
>     mailing list <mailto:x3d-public at web3d.org>
>     *Subject: *[x3d-public] Fwd: Next, in Python news...
>
>     Resend of non-working python code.   No rush,    I don’t want
>     anyone to be surprised.  I do want someone to confirm receipt of
>     email.   I’m guessing things are going to spam?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20210825/cf0f5520/attachment.html>


More information about the x3d-public mailing list