[traits] catching exceptions...

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[traits] catching exceptions...

fred-2
Hi all,

As I have already posted here, I get a lot of issues when I copy Mayavi
modules/filters from one scene and then reintroduce them in another scene.

Last example is in concern with the Text module.

It raises a TraitError exception, about y_position trait being None.

But I _do know_ this is _false_.

So I have to work around this, and thus I have to catch this exception.

But, if I know how to catch exceptions, say, displayed in console, my
try/except seems to catch nothing when messages are displayed in a
dialog :-/

How could I do that?

TIA.

Cheers,

--
Fred

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

snapshot.png (31K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

Robert Kern
On Tue, Dec 28, 2010 at 10:56 AM, Fred <[hidden email]> wrote:
> Hi all,
>
> As I have already posted here, I get a lot of issues when I copy Mayavi
> modules/filters from one scene and then reintroduce them in another scene.

Can you show us the code that does this? A lot hinges on exactly what
you are doing when you "copy" the objects from one scene to another.
If new objects are being created, then it is entirely possible that
whatever is reconstituting the object may try to assign None to
attributes indiscriminately.

> Last example is in concern with the Text module.
>
> It raises a TraitError exception, about y_position trait being None.
>
> But I _do know_ this is _false_.
>
> So I have to work around this, and thus I have to catch this exception.
>
> But, if I know how to catch exceptions, say, displayed in console, my
> try/except seems to catch nothing when messages are displayed in a dialog
> :-/

It's possible you're not putting the try/except around the right bit
of code. Try looking in the Logger view (or the log file, if there is
one) to get the whole traceback.

--
Robert Kern
Enthought
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

fred-2
Le 28/12/2010 23:40, Robert Kern a écrit :
> On Tue, Dec 28, 2010 at 10:56 AM, Fred<[hidden email]>  wrote:
>> Hi all,
>>
>> As I have already posted here, I get a lot of issues when I copy Mayavi
>> modules/filters from one scene and then reintroduce them in another scene.
>
> Can you show us the code that does this? A lot hinges on exactly what
Hi Robert,

I wrote a CME showing the issue, stolen from interactive/multiple_engines.py


Cheers,

--
Fred

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

cme0.py (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

fred-2
Le 29/12/2010 12:52, Fred a écrit :

> I wrote a CME showing the issue, stolen from
> interactive/multiple_engines.py
Another issue, with DataSetClipper filter this time.

I can explain my purpose, why I do this kind of things in my real code,
if needed.


Cheers,

--
Fred

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

multiple_scenes.py (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

Chris Colbert
In reply to this post by fred-2
Hi Fred,

The issue in this CME seems to be line 56 where you are making a copy of the mayavi text object. 

Changing that line to: "text = Text()" and the script runs fine. I can't figure out why at the moment doing that copy is causing the script to fail. The exception says that the y_position is None, but it's definitely not None after the copy, so it may be getting changed somewhere else along the way.

doing copy.copy(text) raises a deprecation warning, but I don't know why it's causing the the call to `add_module` to fail
On Wed, Dec 29, 2010 at 6:52 AM, Fred <[hidden email]> wrote:
Le 28/12/2010 23:40, Robert Kern a écrit :

On Tue, Dec 28, 2010 at 10:56 AM, Fred<[hidden email]>  wrote:
Hi all,

As I have already posted here, I get a lot of issues when I copy Mayavi
modules/filters from one scene and then reintroduce them in another scene.

Can you show us the code that does this? A lot hinges on exactly what
Hi Robert,

I wrote a CME showing the issue, stolen from interactive/multiple_engines.py


Cheers,

--
Fred

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

fred-2
Le 29/12/2010 15:45, Chris Colbert a écrit :
> Hi Fred,
>
> The issue in this CME seems to be line 56 where you are making a copy of
> the mayavi text object.
>
> Changing that line to: "text = Text()" and the script runs fine. I can't

Mmmh, ok, but this is not what I want to do, unhappily :-(

I don't want to create a new instance of Text object.


I guess I have to recall my purpose here ;-)

Say I have a scene1 and scene2 mayavi objects.

My app can add a scene in a background of another:
http://ktools.free.fr/snap1.png

By adding a scene, I mean adding source, and all modules & filters in a
scene from another scene.

And I have to insert all stuff in background before the main scene.

In this case, I insert 4points2 scene in 4points scene, before it.

As I want to put it in background, I recopy the source with its children
(modules &filters), because I don't want to recreate all the stuff
(quite cumbersome to create them in the original scene, so...):
http://ktools.free.fr/snap2.png


My Mayavi pipeline looks like this:
http://ktools.free.fr/snap3.png (4points2 source pipeline unfold)

http://ktools.free.fr/snap4.png (4points source pipeline unfold)

I hope I'm clear on my purpose now, and why I do copy mayavi objects.


Cheers,

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

fred-2
Le 29/12/2010 16:07, Fred a écrit :

> I hope I'm clear on my purpose now, and why I do copy mayavi objects.
Of course, my example works here because I did not copy Text module from
4points scene into 4points2 scene.

If I want to put 4points scene (which has the Text modules) in the
4points2 scene (which only has Labels module), it fails, yes.

Cheers,

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

fred-2
Le 29/12/2010 16:10, Fred a écrit :
> Le 29/12/2010 16:07, Fred a écrit :
>
>> I hope I'm clear on my purpose now, and why I do copy mayavi objects.
> Of course, my example works here because I did not copy Text module from
> 4points scene into 4points2 scene.
>
> If I want to put 4points scene (which has the Text modules) in the
> 4points2 scene (which only has Labels module), it fails, yes.
PS2: Using copy() works fine in most cases, happily.

Only a few cases fail, but it fails completely my app :-(


Cheers,

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

Gael Varoquaux
In reply to this post by fred-2
On Tue, Dec 28, 2010 at 04:56:35PM +0100, Fred wrote:
> As I have already posted here, I get a lot of issues when I copy Mayavi  
> modules/filters from one scene and then reintroduce them in another
> scene.
>
> Last example is in concern with the Text module.
>
> It raises a TraitError exception, about y_position trait being None.
>
> But I _do know_ this is _false_.

Don't rely on copying a complicated graph of objects. As already
discussed on the mailing list, it is non trivial to get code that does
this right. Simply reinstantiate new objects from a domain-specific
representation that encodes what you know is relevent.

G
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [traits] catching exceptions...

fred-2
Le 08/01/2011 23:01, Gael Varoquaux a écrit :

> Don't rely on copying a complicated graph of objects. As already
> discussed on the mailing list, it is non trivial to get code that does
> this right. Simply reinstantiate new objects from a domain-specific
> representation that encodes what you know is relevent.
I have answered here:
https://mail.enthought.com/pipermail/enthought-dev/2010-December/027906.html

How would you do this (copying a scene in a background of another)?

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev