Module has no attribute

16 views
Skip to first unread message

Евгения Вдовина

unread,
Nov 20, 2016, 9:33:31 AM11/20/16
to saga-users
Hi!

I installed saga-python on virtual machine with command "pip install saga-python".


Created new project in Pycharm Community and run an example from http://saga-python.readthedocs.io/en/latest/tutorial/part2.html
But it doesn't work and it's error in console: http://prntscr.com/d9l5q1

What should I do?

Thanks!

Andre Merzky

unread,
Nov 20, 2016, 9:49:41 AM11/20/16
to saga-...@googlegroups.com
Hey!

This line from your screenshot looks suspicious:

module 'saga' from '/home/evgenia/PycharmProjects/testSAGA/saga.pyc'

I would guess that, in the directory where you run 'test.py', you also
have a file 'saga.py'. An 'import saga' will then be interpreted as
request to import that file, not the module somewhere in the Python
library tree. Python is fickly with respect to file and directory
naming like this :/

Please let us know if that turns out to be a wrong assumption, and
we'd be happy to help to debug this further!

Best, Andre.
> --
> You received this message because you are subscribed to the Google Groups
> "saga-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to saga-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
99 little bugs in the code.
99 little bugs in the code.
Take one down, patch it around.

127 little bugs in the code...

Евгения Вдовина

unread,
Nov 23, 2016, 2:00:04 PM11/23/16
to saga-users
Hi, Andre!

I really created file saga.py, but deleted it after first crash and there was no effect.
After your message I created new project and now it's working.

Thank you very much! Now I can start learn saga-python :)

воскресенье, 20 ноября 2016 г., 19:49:41 UTC+5 пользователь Andre Merzky написал:

Andre Merzky

unread,
Nov 23, 2016, 4:10:10 PM11/23/16
to saga-...@googlegroups.com
Thanks for the update - I am glad its working out now! Let us know
if you have any further questions etc, ok?

Best, Andre.

On Wed, Nov 23, 2016 at 8:00 PM, Евгения Вдовина

Евгения Вдовина

unread,
Nov 23, 2016, 4:32:50 PM11/23/16
to saga-users
I wrote a simple program that calculates e^x (using f(x, n) = x^n / n!
It works but I'm sure that it happen in one job ( job == thread ?)

I don't know how check it and can't find a similar sample in saga-python documentation that execute a function in new job.

Can you advise me where can I find this informaton? 

Thank's! 
The code:
import sys
import saga
import math

def main():
    x
= float(input("enter x co calculate exp ^ x: "))
   
try:
        js
= saga.job.Service("fork://localhost")
        jd
= saga.job.Description()
        jd
.environment     = {'MYOUTPUT':'"Hello from SAGA"'}
        jd
.executable      = '/bin/echo'
        jd.arguments       = ['$MYOUTPUT']
        jd
.output          = "mysagajob.stdout"
        jd.error           = "mysagajob.stderr"

        res = 0;

       
for n in range(0,50):
            myjob
= js.create_job(jd)
            myjob
.run()

            result
= (x ** n) / math.factorial(n);
            res
+= result
           
print "Job ID    : %s" % (myjob.id)

            myjob
.wait()

       
print "Res : %s" % (res)
       
return 0

    except saga.SagaException, ex:
       
print "An exception occured: (%s) %s " % (ex.type, (str(ex)))
       
print " \n*** Backtrace:\n %s" % ex.traceback
       
return -1


if __name__ == "__main__":
    sys
.exit(main())



четверг, 24 ноября 2016 г., 2:10:10 UTC+5 пользователь Andre Merzky написал:

Andre Merzky

unread,
Nov 28, 2016, 3:54:31 AM11/28/16
to saga-...@googlegroups.com
Ah, I think this needs clarification indeed!

the SAGA job package is about starting *jobs*, in the sense of
*external programs* (external executables). So you can use it to
start an external application code, but it is not easily able to spawn
out python subroutines. For that purpose, you may want to look into
the python 'multiprocessing' module.

In your code below, the external program you start is '/bin/echo', and
presumably that will run all right. The calculation for loop you
define will though simply run in your python script proper, and will
not be part of the remote execution.

If you don't mind, could you describe your target use case, i.e. what
you are trying to achieve with remote execution? I would be happy to
help mapping that to the SAGA semantics, if suitable.

Best regards,

Andre.


On Wed, Nov 23, 2016 at 10:32 PM, Евгения Вдовина
Reply all
Reply to author
Forward
0 new messages