getstream / stream-python Goto Github PK
View Code? Open in Web Editor NEWPython Client - Build Activity Feeds & Streams with GetStream.io
Home Page: https://getstream.io
License: BSD 3-Clause "New" or "Revised" License
Python Client - Build Activity Feeds & Streams with GetStream.io
Home Page: https://getstream.io
License: BSD 3-Clause "New" or "Revised" License
Python 2 support ended so we can safely drop our support too.
Hi all,
We're trying to integrate this library into our app, but have been having some issues because our app is hosted on Google App Engine Standard Environment. A similar issue was filed a few months ago and your team sent a PR to requests_toolbelt
to fix the error, but the error is still there.
I followed the advice of the OP of issue #43 and changed line 9 in client.py
and so far it seems to be working. Would it be possible to add this to the library?
Also, the fix your team merged into requests_toolbelt
is no longer in their codebase, and manually adding that fix back in there produces a recursion error.
Calling feed.add_activity(activity_data)
without changing line 9 in client.py
produces the following error:
ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))
Operating System: Ubuntu 14.04
Python version: 2.7
Library version:
requests-toolbelt==0.7.0
stream-python==2.3.9
It can't contain / or :
and should match our specified regex
@tbarbugli
what do you think?
Something is going wrong with exception handling and the response exception is replaced by an InputException without any message.
very often setup install fails with this error:
running test
Searching for httpsig==1.1.2
Reading https://pypi.python.org/simple/httpsig/
No local packages or download links found for httpsig==1.1.2
error: Could not find suitable distribution for Requirement.parse('httpsig==1.1.2')
There is clearly something really broken in httpsig library
USER_AGENT should be "stream-python-client-%(version)s"
follows = [
{'source': 'group:1', 'target': 'user:1'},
{'source': 'group:1', 'target': 'user:2'},
]
stream_client.follow_many(follows,activity_copy_limit=10)
Is there a feature for bulk un-follow just like follow_many?
[ to: ] keyword v/s follow feature. Can you elaborate case which one to use specifically?
Hello, I have been using the stream api to develop an app .. one of the models that I had in the stream was removed from the database .. and now I would like to remove that data from the stream ..
Right now activity.time does not have timezone information making life harder. Stream returns UTC datetimes so it is correct to localize them as such.
Whenever i delete a user in my staging enviorment because of the way my model delete cascade a singal request is made per deleted model of Follow type.
This causes a rate limit error to be hit
However if there was a bulk unfollow method I could than in my user model pre delete signal
get all the follow models that are related and bulk delete them from the stream api.
Im not to concern for the signal being firred when i delete the Follows because it would be a bulk delete operation that doesn't fire a signal.
Having stream-python installed with say djangorestframework-jwt raises this notice
PyJWT is at 1.6.4, but stream-python is still tied to 1.3.0
Install stream-python, then install latest pyjwt (or any package that depends on the latest pyjwt)
Windows 10
Python version: 3.6.2
Library version: stream-python 2.9.0 (installing stream_django)
Issue has been opened for this in the past
#20
Suggested api
user_feed_1 = client.feed('user:1')
token = user_feed_1.get_token()
Our documentation at Stream advises Python users to fetch a list of feeds a user follows by calling the .following() method with a parameter to pass in a list of feeds to filter by, but also includes a filter
parameter which goes unused. Our documentation will be updated, but perhaps this unused parameter should be removed from the SDK as well? Since this could potentially cause a breaking change for our SDK users, perhaps we should also bump the minor version from 2.3 to 2.4.
Line 184 in 1d9b95a
Hey team,
I just started playing around with this client and because of some issues with App Engine and the requests library it took me a while.
In order to get it working I used requests_toolbelt which uses an Adapter compatible with App Engine.
A quick fix on your end to make it compatible would just be to update line 9 in client.py to
from requests.sessions import HTTPAdapter
as this is what's being patched by request_toolbelt as seen in the link below.
Unable to retrive specific kind of reactions.
client.reactions.filter(activity_id="ed2837a6-0a3b-4679-adc1-778a1704852d", kind="like", limit=4)
here I want to retrive the reactions of kind "like" but in response it gives all kinds of reactions.
Sample JSON Output:
{
'next': '/api/v1.0/reaction/activity_id/9fa96c96-94e9-808003-cde8-d71/?api_key=ztusu5zkphgg&id_lt=c2bd55be-972b-4ddf63bfcc&kind=like&limit=4',
'results': [
{
'created_at': '2019-06-21T12:16:48.945974Z',
'updated_at': '2019-06-21T12:16:48.945974Z',
'id': '2c38fd40-ea42-45ee-adda-7cf8447c633e',
'user_id': '27',
},
'kind': 'like',
'activity_id': '9fa96c96-9407-11e9-8080-80003cde8d71',
},
{
'created_at': '2019-06-21T11:15:16.156967Z',
'updated_at': '2019-06-21T11:15:16.156967Z',
'id': '41ad8abb-4814-4ad2-a1ab-6a090ebc0d63',
'user_id': '45',
},
'kind': 'like',
'activity_id': '9fa96c96-9407-11e9-8080-80003cde8d71',
'data': {
},
'parent': '',
'latest_children': {
},
'children_counts': {
}
},
{
'created_at': '2019-06-21T10:39:39.460565Z',
'updated_at': '2019-06-21T10:39:39.460565Z',
'id': '6990fcb2-bbda-462e-aa0d-992fe236be71',
'user_id': '45',
'kind': 'comment',
'activity_id': '9fa96c96-9407-11e9-8080-80003cde8d71',
'data': {
'text': 'Hello'
},
'parent': '',
'latest_children': {
},
'children_counts': {
}
},
{
'created_at': '2019-06-21T10:38:28.438077Z',
'updated_at': '2019-06-21T10:38:28.438077Z',
'id': 'a1ff6918-423a-428b-b3c8-6dbaddbfb028',
'user_id': '45',
'kind': 'comment',
'activity_id': '9fa96c96-9407-11e9-8080-80003cde8d71',
'data': {
'text': 'Nice'
},
'parent': '',
'latest_children': {
},
'children_counts': {
}
}
],
'duration': '2.48ms'
}
mark_seen=[aid1, aid2] -> mark_seen="aid1,aid2"
install_requires = [
'pyjwt==1.3.0',
'requests>=2.2.1',
'six>=1.8.0',
'httpsig==1.1.2'
]
-> 'httpsig==1.1.2'
https://pypi.python.org/pypi/httpsig
Requirements
Python 2.7, 3.2, 3.3, 3.4
PyCrypto
PyCrypto is officially dead see pycrypto/pycrypto#238 - and wont compile on python 3.6 windows systems.
consider moving away from an outdated httpsig 2015-Feb-11
if you add an activity
activity = dict(to=['a'])
feed.add_activity(activity)
activity.to no longer equals ['a']
it's edited in place....
What about we retry (3 times?) failed requests to APIs?
requests comes with a simple retry mechanism:
http://stackoverflow.com/questions/15431044/can-i-set-max-retries-for-requests-request
unfortunately retries requests are done immediately after the failure.
perhaps it makes more sense to have retries sleeping an increasing amount of time between each other (eg. 0.5s; 1s; 2s; 4s; 8s; fail)
It is currently not possible to use both stream-python
and stream-chat-python
within the same python environment, due to pycryptodomex
requires version dependency.
It would be pretty easy to relax the dependency with >= (instead of strict equal), in both projects
pip install stream-python stream-chat-python
OSX 10.14.5
Python version: 3.7.4
Library version: 3.1.0
ERROR: stream-chat 1.0.1 has requirement pycryptodomex==3.8.1, but you'll have pycryptodomex 3.4.7 which is incompatible.
n/a
Nothing specifically wrong but could be improved, IMHO.
response = self.client.post(
resource,
service_name="personalization",
params=params,
signature=self.token,
data=data,
)
return response
Generally, previous idiom is followed but response
could be returned directly without losing any significant information but it might improve readability by making implementation shorter since it's repeated many times.
Suggestion is as following:
- response = self.client.post(
+ return self.client.post(
resource,
service_name="personalization",
params=params,
signature=self.token,
data=data,
)
- return response
None, above description is self contained.
N/A
N/A
N/A
If activity_list
is passed in add_activities as an empty list, then the client will make a request to the API and crash with an uncaught & obscure error message. Don't have the logs already, but it was complaining that necessary fields like verb
, actor
were missing.
send target_token as part of post body containing the signature token of the target feed id (eg. secret:42)
the test account has a private feed configured (slug secret)
https://stream-python.readthedocs.io/en/latest/ is outdated.
Should still support or drop the reference not to mislead users?
Traceback (most recent call last):
File "examples/etoro_example.py", line 46, in
activity_response = user_feed_crembo.add_activities(activities)
File "/Users/thierryschellenbach/workspace/stream-python/stream/feed.py", line 82, in add_activities
self.feed_url, data=data, signature=token)
File "/Users/thierryschellenbach/workspace/stream-python/stream/client.py", line 203, in post
return self._make_request(self.session.post, _args, *_kwargs)
File "/Users/thierryschellenbach/workspace/stream-python/stream/client.py", line 170, in _make_request
return self._parse_response(response)
File "/Users/thierryschellenbach/workspace/stream-python/stream/client.py", line 115, in _parse_response
self.raise_exception(parsed_result, status_code=response.status_code)
File "/Users/thierryschellenbach/workspace/stream-python/stream/client.py", line 186, in raise_exception
for field, errors in exception_fields.items():
AttributeError: 'list' object has no attribute 'items'
The httpsig dependency is failing to install because it's 404ing on PyPI, which means stream-python
fails to install. Just wanted to make you guys aware:
$ pip install stream-python
Downloading/unpacking stream-python
Downloading stream-python-2.2.1.tar.gz
Running setup.py egg_info for package stream-python
Downloading/unpacking requests>=2.3.0 (from stream-python)
Downloading requests-2.7.0.tar.gz (451kB): 451kB downloaded
Running setup.py egg_info for package requests
Downloading/unpacking six>=1.8.0 (from stream-python)
Downloading six-1.9.0.tar.gz
Running setup.py egg_info for package six
no previously-included directories found matching 'documentation/_build'
Downloading/unpacking httpsig==1.1.0 (from stream-python)
Could not find any downloads that satisfy the requirement httpsig==1.1.0 (from stream-python)
Cleaning up...
No distributions at all found for httpsig==1.1.0 (from stream-python)
Storing complete log in /Users/max/.pip/pip.log
Mentioned here: ahknight/httpsig#5
Currently there is a create_activities methods for feeds but I don't see a remove_activities equivalent.
some code is not covered by test: https://coveralls.io/github/GetStream/stream-python
I expect to see only user's own reactions, but instead I get all reactions, regardless of who they came from.
feed = client.feed('user', 'alice');
response = feed.get(limit=30, enrich=True, reactions: {"counts": true, "recent": true, "own": true})
Operating System:
Python version:
Library version:
[put traceback here]
feed = client.feed('user', 'alice');
response = feed.get(limit=30, enrich=True, reactions: {"counts": true, "recent": true, "own": true})
I want the most recent edited, so I want to update the activity and have it show up firs
This is what Im currently using.
37 feeds = feed_manager.get_news_feeds(self.request.user.id)
38 activities = feeds.get('timeline').get()['results']
My server side generation of read only tokens looks like the following:
from stream_django.client import stream_client
def jwt_response_payload_handler(token, user=None, request=None):
user_feed_1 = stream_client.feed('user', str(user.id))
readonly_token = user_feed_1.get_readonly_token()
return {
'token': token,
'stream': str(readonly_token)
}
JWT_AUTH = {
'JWT_RESPONSE_PAYLOAD_HANDLER': jwt_response_payload_handler
}
My client side code looks like the following:
function setupStream (token, id) {
var client = stream.connect('te5vptfdhrss', null, '10287')
var user1 = client.feed('user', id, token)
debugger
function callback (data) {
console.log(data)
}
function failCallback (data) {
alert('something went wrong, check the console logs')
console.log(data)
}
user1.get({ limit: 5, offset: 0 })
.then(callback)
.catch(failCallback)
// user1.subscribe(callback).then(() => {}, failCallback)
}
I get an error message of the following:
{
"code": null,
"detail": "url signature missing or invalid",
"duration": "10ms",
"exception": "AuthenticationFailed",
"status_code": 403
}
HOWEVER:
if i change the token to be read/write, the client side code doesn't produce an error.
readonly_token = user_feed_1.token
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.