Git Product home page Git Product logo

syncano-python's Introduction

Syncano

Build Status

Master

https://circleci.com/gh/Syncano/syncano-python/tree/master.svg?style=svg&circle-token=738c379fd91cc16b82758e6be89d0c21926655e0

Develop

https://circleci.com/gh/Syncano/syncano-python/tree/develop.svg?style=svg&circle-token=738c379fd91cc16b82758e6be89d0c21926655e0

Python QuickStart Guide

You can find quick start on installing and using Syncano's Python library in our documentation.

For more detailed information on how to use Syncano and its features - our Developer Manual should be very helpful.

In case you need help working with the library - email us at [email protected] - we will be happy to help!

You can also find library reference hosted on GitHub pages here.

syncano-python's People

Contributors

23doors avatar adamwardecki avatar dancio avatar devintyler avatar ericschles avatar forgems avatar ilonajulczuk avatar ilu2112 avatar kotchaosu avatar mariuszwisniewski avatar mkucharz avatar opalczynski avatar pekoslaw avatar zhebr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

syncano-python's Issues

Instance admin doesn't update, however from library it looks like it should update

Here, I get an admin object and try to change its first name:

Out[59]: <InstanceAdmin: 2>

In [60]: ad.first_name
Out[60]: u'Robert'

In [61]: ad.first_name
Out[61]: u'Robert'

In [62]: ad.first_name = 'Roberto'

In [63]: ad.save()
Out[63]: <InstanceAdmin: 2>

In [64]: ad.first_name
Out[64]: u'Robert'

In [65]: ad.first_name = 'Roberto'

In [66]: ad.first_name
Out[66]: 'Roberto'

After save it returns to the original version which is a really weird behavior.

Can't connect to default syncano API, because of certificate verification

Retrieving anything from api fails badly with SSLError:

SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

It should be either treated as a warning or library user should have an easy way to configure library to ignore this issue. Reading a readme I don't know yet how to fix this.

Manager enhancements

It would be nice if manager list output could support methods such as first() and count() and additionally at least basic indexing.

In [14]: instance.api_keys.list().first()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-636bd0c88b8c> in <module>()
----> 1 instance.api_keys.list().first()

AttributeError: 'Manager' object has no attribute 'first'

In [15]: instance.api_keys.list()[0]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-ed6c20304f8d> in <module>()
----> 1 instance.api_keys.list()[0]

TypeError: 'Manager' object does not support indexing

In [16]: api_keys = list(instance.api_keys.list())
In [17]: api_keys[0]
Out[17]: <ApiKey: 1>

In [18]: instance.api_keys.list().count()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-18-e2e7199079c8> in <module>()
----> 1 instance.api_keys.list().count()

AttributeError: 'Manager' object has no attribute 'count'

Syncano connect should provide better documentation

In [10]: syncano.connect?
Type: function
String form: <function connect at 0x7f64001d4140>
File: /home/att/Projects/syncano-python/syncano/init.py
Definition: syncano.connect(_args, *_kwargs)
Docstring: Connect to Syncano API.

It isn't very helpful - what can I provide here as args of kwargs?

updating class doesn't reflect in dashboard...

I'm using this code to update/add fields to an exisiting class....

import syncano                                                                                                                              
import time
from lib import settings
from syncano.models import Object
from syncano.models import Class

settings = settings.ConfigMixin()

connection = syncano.connect(api_key=settings.syncanoAccountKey)
CLASS_NAME = Class.please.get(instance_name='global', name='inappuserevents')
print(CLASS_NAME)
CLASS_NAME.schema.add = [{"name": "remoteid", "type": "string"}]

the dashboard isn't reflecting any changes...

what gives?

thx

I can't reach user profile

I have additional field in my user profile github_login, I see that it is coming with the "raw" request:

In [218]: connection.User.please.raw().get(id=1)
Out[218]:
{u'groups': [],
 u'id': 1,
 u'links': {u'groups': u'/v1.1/instances/test/users/1/groups/',
  u'profile': u'/v1.1/instances/test/classes/user_profile/objects/1/',
  u'reset-key': u'/v1.1/instances/test/users/1/reset_key/',
  u'self': u'/v1.1/instances/test/users/1/'},
 u'profile': {u'channel': None,
  u'channel_room': None,
  u'created_at': u'2016-05-31T18:33:41.408006Z',
  u'github_key': u'KEY',
  u'github_login': u'LOGIN',
  u'group': None,
  u'group_permissions': u'none',
  u'id': 1,
  u'links': {u'owner': u'/v1.1/instances/test/users/1/',
   u'self': u'/v1.1/instances/test/classes/user_profile/objects/1/'},
  u'other_permissions': u'none',
  u'owner': 1,
  u'owner_permissions': u'full',
  u'revision': 4,
  u'updated_at': u'2016-06-04T22:54:34.221236Z'},
 u'user_key': u'KEY',
 u'username': u'EMAIL}

But I can't reach it that way:

In [219]: connection.User.please.get(id=1)

(github_login available is not in the user profile object)

my_class.objects.create fails

Creating object fails:

In [32]: brunia.schema
Out[32]: 
[{u'name': u'henryk', u'type': u'string'},
 {u'name': u'zygmunt', u'type': u'string'}]

In [33]: brunia.objects.create(henryk='123', zygmunt='uhuh')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-33-df18dd6b05c7> in <module>()
----> 1 brunia.objects.create(henryk='123', zygmunt='uhuh')

/home/att/Envs/wild-fantasy/lib/python2.7/site-packages/syncano-4.0.0-py2.7.egg/syncano/models/manager.pyc in create(self, **kwargs)
     96 
     97         instance = self.model(**attrs)
---> 98         instance.save()
     99 
    100         return instance

/home/att/Envs/wild-fantasy/lib/python2.7/site-packages/syncano-4.0.0-py2.7.egg/syncano/models/base.pyc in save(self, **kwargs)
    105         method = 'POST'
    106 
--> 107         if self.links:
    108             endpoint = self.links['self']
    109             methods = self._meta.get_endpoint_methods('detail')

AttributeError: 'Object' object has no attribute 'links'

callbacks.py issue

There is a python module called callbacks. Could we consider changing the name so that there is no conflict in case someone already has the module installed?

This is for the simple reason that someone may want to do the following:

import callbacks AND
from syncano import callbacks

Strange repr error in instance.classes

In [6]: instance.classes
Out[6]: <repr(<syncano.models.manager.Manager at 0x7f48240c5510>) failed: TypeError: __repr__ returned non-string (type generator)>

It turns out that it happens in other places too:

instance.api_keys
Out[7]: <repr(<syncano.models.manager.Manager at 0x7f48240c5910>) failed: TypeError: __repr__ returned non-string (type generator)>

Convert date fields to datetime object

I think that library should deal with date fields and convert them to datetime object, right now field looks like this:

{u'type': u'datetime', u'value': u'2016-06-09T17:05:47.861890Z'}

Bug: User model

when trying to list the users in my instance (see following code)

syncano.connect(api_key=API_KEY)
users = User.please.list(instance_name=INSTANCE)
for user in users:
    # print(user)
    print(user.user_key)

I get the following error:

Traceback (most recent call last):
File "_**syncano_backend/test/test.py", line 34, in
for user in users:
File "/usr/local/lib/python3.5/dist-packages/syncano/models/manager.py", line 812, in iterator
yield self.serialize(o)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/manager.py", line 741, in serialize
return model(__properties) if self._serialize else data
File "/usr/local/lib/python3.5/dist-packages/syncano/models/archetypes.py", line 90, in init
self.to_python(kwargs)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/archetypes.py", line 247, in to_python
setattr(self, field.name, value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/fields.py", line 105, in set
instance.raw_data[self.name] = self.to_python(value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/fields.py", line 524, in to_python
return self.rel(
*value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/classes.py", line 145, in new
raise SyncanoValidationError('Field "instance_name" is required.')
syncano.exceptions.SyncanoValidationError: Field "instance_name" is required.

I tested my api key in http://docs.syncano.io/v0.1.1/docs/users-list and it worked. It looks like the python lib cant create a user model object from the response.

Code from the stacktrace


   def serialize(self, data, model=None):
        """Serializes passed data to related :class:`~syncano.models.base.Model` class."""
        model = model or self.model
        if data == '':
            return

        if isinstance(data, model):
            return data

        if not isinstance(data, dict):
            raise SyncanoValueError('Unsupported data type.')

        properties = deepcopy(self.properties)
        properties.update(data)
        return model(**properties) if self._serialize else data`


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.