GithubHelp home page GithubHelp logo

cnr-ibba / pyusirest Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 163 KB

Python USI submission REST API contain all methods to interact with EMBL-EBI Unified Submissions Interface

License: Other

Makefile 2.07% Python 97.93%

pyusirest's People

Contributors

bunop avatar

Stargazers

 avatar

Watchers

 avatar  avatar

pyusirest's Issues

root.get_user_teams() raise Exception when no teams are found

Describe the bug
Getting teams from a Root object raises KeyError: 'teams' if no team is found

To Reproduce

from pyUSIrest.auth import Auth
from pyUSIrest.client import Root
auth = Auth(user='image-lPvdsc50', password='***')
root = Root(auth)
root.get_user_teams()

Expected behavior
A message like "no teams found for user ...." or even a more informative exception like "you need to create at least a team"

Additional context

/usr/local/lib/python3.6/site-packages/pyUSIrest/client.py in get_user_teams(self)
    470
    471         # now iterate over teams and create new objects
--> 472         for i, team_data in enumerate(document._embedded['teams']):
    473             teams.append(Team(self.auth, team_data))
    474             logger.debug("Found %s team" % (teams[i].name))

KeyError: 'teams'

:bug: Patching samples raises USIConnectionError

Describe the bug
Patching a sample in a Draft biosample submission returns:

USIConnectionError: 400:{"type":"/api/docs/submission_api.html#_errors","title":"Bad Request","status":400,"instance":"uri=/api/samples/xxxxxxxxxxxxxxxxxxxx","errors":["Malformed JSON request"]}

The issue seems to be related on how relationship are read from Sample object: team should be expressed as str and not as Team.data dictionary

To Reproduce
Steps to reproduce the behavior:

  1. Create a Submission
  2. Add a Sample to a Submission
  3. Patch Sample even with the same data
  4. Got the USIConnectionError

Expected behavior
Sample need to be patched without errors

Additional context

  • A 40x return status code should be modeled as USIDataError not USIConnectionError (50x)
  • model Sample.team attribute like Submission.team

:bug: pyUSIrest can't submit data with the current BioSample services

Describe the bug
BioSamples API has changed and this library can't deal with data submission. Root and others methods need to point to the proper API urls

To Reproduce
Try to instantiate a new Root class or create and submit data into BioSamples service

Expected behavior
Methods need to be updated in order to user the proper API url. Documents need to described how a submission can be made with the current URLs

Additional context
Try to understand the API submission system and define new python object to automate some stuff

Use iterators when browsing USI objects

Is your feature request related to a problem? Please describe.
Data are collected and stored locally in dictionaries, however this raise issues when accessing submission with a lot of samples since all those data are stored in memory. Since the majority of tasks are iterating over objects, will be nice to iterate over objects without reading all data in memory.

Describe the solution you'd like
Methods like Root.get_user_submissions() and Submission.get_samples() need to reply with an iterator object. If a user need the list representation of its objecs, will call list() on iterator object

Describe alternatives you've considered
We could store information data in local objects and accessing them using direct links. The code as it is published in pypi works, the only drawback is the memory used while accesing a lot of data.

Additional context
There are other points that could enhance this library, they are also described in 0.3.0.dev0. Scrutinizer rating could be improved to facilitate code maintenance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.