{"id":27881769,"url":"https://github.com/src-d/lookout-sdk","last_synced_at":"2025-05-05T05:04:55.195Z","repository":{"id":62576866,"uuid":"146800972","full_name":"src-d/lookout-sdk","owner":"src-d","description":"SDK for lookout analyzers","archived":false,"fork":false,"pushed_at":"2019-12-14T15:00:44.000Z","size":278,"stargazers_count":4,"open_issues_count":9,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-05T05:04:49.479Z","etag":null,"topics":["golang","grpc","lookout","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/src-d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-30T20:06:37.000Z","updated_at":"2019-10-09T11:35:27.000Z","dependencies_parsed_at":"2022-11-03T19:11:30.904Z","dependency_job_id":null,"html_url":"https://github.com/src-d/lookout-sdk","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/src-d%2Flookout-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/src-d%2Flookout-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/src-d%2Flookout-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/src-d%2Flookout-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/src-d","download_url":"https://codeload.github.com/src-d/lookout-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252442484,"owners_count":21748451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","grpc","lookout","python"],"created_at":"2025-05-05T05:04:54.556Z","updated_at":"2025-05-05T05:04:55.187Z","avatar_url":"https://github.com/src-d.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lookout-sdk [![GitHub version](https://badge.fury.io/gh/src-d%2Flookout-sdk.svg)](https://github.com/src-d/lookout-sdk/releases) [![PyPI version](https://badge.fury.io/py/lookout-sdk.svg)](https://pypi.org/project/lookout-sdk/) [![Build Status](https://travis-ci.com/src-d/lookout-sdk.svg?branch=master)](https://travis-ci.com/src-d/lookout-sdk) [![GoDoc](https://godoc.org/gopkg.in/src-d/lookout-sdk.v0?status.svg)](https://godoc.org/gopkg.in/src-d/lookout-sdk.v0/pb)\n\nToolkit for writing new analyzers for **[source{d} Lookout](https://github.com/src-d/lookout)**.\n\n\n# What Does the SDK Provide?\n\n_For the complete documentation of **source{d} Lookout**, please take a look at [https://docs.sourced.tech/lookout](https://docs.sourced.tech/lookout)._\n\n_For detailed information about the different parts of Lookout, and how they interact you can go to the [Lookout architecture guide](https://docs.sourced.tech/lookout/architecture)._\n\n**lookout-sdk** provides:\n\n- **proto [definitions](./proto)**.\n- pre-generated libraries for [Golang](./pb) and [Python](./python), offering:\n  - an easy **access to the DataService API though a gRPC service**. Lookout will take care of dealing with Git repositories, UAST extraction, programming language detection, etc.\n  - low-level **helpers to work around some protobuf/gRPC caveats**.\n- quickstart [examples](./examples) of an Analyzer that detects language and number of functions (written in Go and in Python).\n\n\n# Caveats\n\nFor the gRPC client and server please follow these requirements:\n- set a common maximum gRPC message size in gRPC servers and clients. This is required to avoid hitting different gRPC limits when handling UASTs, that can be huge \u0026mdash;see [grpc/grpc#7927](https://github.com/grpc/grpc/issues/7927)\u0026mdash;. To do so use the included helpers in lookout-sdk:\n  - go: using `pb.NewServer` and `pb.DialContext`.\n  - python: using `lookout.sdk.grpc.create_server` and `lookout.sdk.grpc.create_channel`.\n- support [RFC 3986 URI scheme](https://github.com/grpc/grpc-go/issues/1911); lookout-sdk includes helpers for this:\n  - go: using `pb.ToGoGrpcAddress` and `pb.Listen`.\n  - python: using `lookout.sdk.grpc.to_grpc_address`.\n- use insecure connection:\n  - currently lookout expects to use insecure gRPC connections, as provided by `pb.DialContext`\n  - python: run server using `server.add_insecure_port(address)` ([example](https://github.com/src-d/lookout-sdk/blob/master/examples/language-analyzer.py#L63)).\n\n## DataService\n\nWhen DataService is being dialed, you should:\n\n- turn on [gRPC Wait for Ready](https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md) mode if your analyzer creates a connection to DataServer before it was actually started. This way the RPCs are queued until the chanel is ready:\n  - go: using [`grpc.WaitForReady(true)`](https://godoc.org/google.golang.org/grpc#WaitForReady).\n  - python: using the [`wait_for_ready`](https://grpc.io/grpc/python/grpc.html) flag.\n- golang: reset connection backoff to DataServer on event:\n    if you keep the connection to DataServer open you need to reset the backoff when your analyzer receives a new event. Use the [`conn.ResetConnectBackoff`](https://godoc.org/google.golang.org/grpc#ClientConn.ResetConnectBackoff) method in your event handlers. It's needed to avoid broken connections after a `lookoutd` redeployment. In case of a long restart of `lookoutd` gRPC server, the backoff timeout may increase so much that the analyzer will not be able to reconnect before it makes the new request to DataServer.\n\n\n# Contributing\n\nContributions are **welcome and very much appreciated** 🙌\n\nPlease refer [to our Contribution Guide](docs/CONTRIBUTING.md) for more details.\n\n\n## Community\n\nsource{d} has an amazing community of developers and contributors who are interested in Code As Data and/or Machine Learning on Code. Please join us! 👋\n\n- [Slack](http://bit.ly/src-d-community)\n- [Twitter](https://twitter.com/sourcedtech)\n- [Email](mailto:hello@sourced.tech)\n\n\n# Code of Conduct\n\nAll activities under source{d} projects are governed by the [source{d} code of conduct](.github/CODE_OF_CONDUCT.md).\n\n\n# License\n\nApache License Version 2.0, see [LICENSE](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrc-d%2Flookout-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrc-d%2Flookout-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrc-d%2Flookout-sdk/lists"}