Question: Custom tool produce empty outputs
0
gravatar for luana.brancato
2.1 years ago by
luana.brancato0 wrote:

Hello everyone.

I'm new to both Galaxy and python, so forgive me if my issue turns out to be silly. I'm developing a simple suite of tools that perform a series of REST calls and process the results. The simplest of them calls the service and expects a json file in return.

When I call the function from command line, it correctly writes the output on file (same path where galaxy should write, same user). However, when I call it through Galaxy, only an empty file is produced.

This is the tool xml file:

<tool id="rest-login" name="REST Login" version="0.1.0">
  <description>Login in the platform</description>
  <command interpreter="python">rest-auth.py $output -cmd=login -login_type=%authType.type
      </command>
  <inputs>
    <conditional name="authType">
        <param name="login_type" type="select" label="Log as guest or registered?">
            <option value="guest">Guest</option>
            <option value="registered">Registered User</option>         
        </param>
        <!-- For now, unused -->
        <when value="registered">
            <param name="user" type="text" label="Username"></param>
            <param name="password" type="text" label="Password"></param>
        </when>
    </conditional>
  </inputs>
  <outputs>
    <data format="json" name="output" label="current_user" />
  </outputs>
</tool>

While this is the code snippet that makes the call, given the output destination as argument:

def guest_login(output):

    req = urllib2.Request('http://example.com/rest-service')
    req.add_header('Accept', 'application/json')
    res = urllib2.urlopen(req)

    res_str = res.read().decode('utf8')

    with open(output, 'w') as f_out : 
        json.dump(res_str,f_out)
    f_out.close

Thanks in advance!
Luana

tool development galaxy custom • 872 views
ADD COMMENTlink modified 2.1 years ago by Jennifer Hillman Jackson25k • written 2.1 years ago by luana.brancato0
0
gravatar for luana.brancato
2.1 years ago by
luana.brancato0 wrote:

As expected, it turned out to be a pretty silly detail. The error was in the login_type parameter, I typed wrong the input param name ('authType.type' instead of 'authType.login_type'). Now it correctly works.

ADD COMMENTlink written 2.1 years ago by luana.brancato0

Glad you worked this out! Jen, Galaxy team

ADD REPLYlink written 2.0 years ago by Jennifer Hillman Jackson25k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 168 users visited in the last hour