sbg / sevenbridges-python

SevenBridges Python Api bindings
Apache License 2.0
46 stars 27 forks source link

Queries work but creating projects or tasks does not #123

Closed gabrielle-altman closed 3 years ago

gabrielle-altman commented 3 years ago

Hi,

I have just started using the API on python and I was working on the tutorial to learn how to use it. I noticed that when I use query functions like api.billing_groups.query() it works correctly, so I assume the API is connected to my account on Cavatica properly. However, when I try to create a new project or new task, nothing seems to actually go through. No error messages are produced but when I query projects or tasks the new one does not show up and I also cannot see it on my account. Additionally, an object is produced by creating a new project or file but it does not have an ID, name, or any other information in the object.

I'm not sure how to proceed to fix this since it does seem that the API is connected to my account by querying correctly.

Thanks for the help!

QuicksilverMachine commented 3 years ago

Hey @gabrielle-altman, the latest documentation for sevenbridges-python is at https://sevenbridges-python.readthedocs.io/en/latest/quickstart/. The tutorial you linked has not been updated in years, and I'm not sure it's still correct. If you have any issues after that, please let us know.

gabrielle-altman commented 3 years ago

Hi @QuicksilverMachine thank you for the fast response! I just went to the latest documentation and used the exact code they have for creating a new project (shown below) and it still does not work.

# Grab the first billing group
bg = api.billing_groups.query(limit=1)[0]

# Create a project using the billing group grabbed above
new_project = api.projects.create(name="My new project", billing_group=bg.id)

When I have python print the new_project variable it returns: <Project: id=None> It does not have any name assigned to it. No errors show up, so I am unsure what is causing this.

Thanks for the help!

QuicksilverMachine commented 3 years ago

@gabrielle-altman Could you tell me which version of sevenbridges-python you're using and if it works with the latest one? Also, did you install it using pip or something else?

gabrielle-altman commented 3 years ago

@QuicksilverMachine through pip I had version 1.1.1. I also just (a couple of minutes ago so I assume it was the latest version) tried installing via git and then using the setup.py to install. It still doesn't work for either.

QuicksilverMachine commented 3 years ago

Strange, I managed to make it work with both, could you try running this script in your environment and see if that creates a project for you?

api = sevenbridges.Api(
    url='https://cavatica-api.sbgenomics.com/v2',
    token='your_token',
)

bg = api.billing_groups.query(limit=1)[0]
new_project = api.projects.create(name="myproject", billing_group=bg.id)
print(new_project)
gabrielle-altman commented 3 years ago

@QuicksilverMachine now it is working! thank you! The only thing that was different was that before I used import sevenbridges as sbg and then in the API creation did sbg.Api(...) but this time just used import sevenbridges and your code and it works now.

QuicksilverMachine commented 3 years ago

@gabrielle-altman I figured out what it was, you might have been using http instead of https when setting api url. Creating a project is a POST request and does not handle redirects to https. Both import types work fine for me.