uber / clay Goto Github PK
View Code? Open in Web Editor NEWClay is a framework for building RESTful backend services using best practices. It’s a wrapper around Flask.
Home Page: http://clayframework.com/
License: Other
Clay is a framework for building RESTful backend services using best practices. It’s a wrapper around Flask.
Home Page: http://clayframework.com/
License: Other
Hi there,
The clay docs url is down. The last working cached version I found was: http://web.archive.org/web/20130402234650/http://uber.github.com/clay/
note I'm using clay.asciidoc; but it seems like the url should be available as well.
I just renamed the config on one of our projects from .json to .yaml. I expected supervisior to fail to start the service once I updated the supervisor ini, but the service was running. I think we should change it so that if a config fails to load, clay throws an exception.
Consider the following check:
https://github.com/uber/clay/blob/master/clay/database.py#L18
This line should be written as:
if dbapi_name not in ('psycopg2', 'MySQLdb', 'sqlite3'):
not dbapi_name
will evaluate to a boolean, which will never be present in the tuple.
Hey @synack,
How would you feel with having this function in a fabric_utils
module in clay
?
https://github.com/uber/cleopatra/blob/master/cleopatra/lib/fabric_utils.py#L13
(something more abstract obviously - just look at the general idea)
ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
DEFAULT_ENVIRONMENT = "local"
DEFAULT_CONFIG_FILENAME = "config/{environment}.yaml"
ENV_VAR_PREFIX = "export CLAY_CONFIG={root_path}/{config_filename}"
def localenv(*args, **kwargs):
"""Execute cmd in local environment."""
# Remove empty keys
kwargs = {k: v for k, v in kwargs.items() if v}
template_vars = {
"root_path": ROOT_PATH,
"environment": kwargs.pop("environment", DEFAULT_ENVIRONMENT),
"config_filename": kwargs.pop("config_filename", DEFAULT_CONFIG_FILENAME)
}
# By default, the config filename includes the role name,
# that's why we need to format it.
template_vars["config_filename"] = kwargs.pop(
"config_filename",
DEFAULT_CONFIG_FILENAME).format(**template_vars)
env_prefix = ENV_VAR_PREFIX.format(**template_vars)
with prefix(env_prefix):
return local(*args, **kwargs)
Hi,
First, I want to say thanks for open sourcing Clay and @synack for helping me out earlier. Thought I'd try submitting a question here.
I'm trying to move my local Clay app to production, specifically to Heroku.
When I run this,
gunicorn clay.wsgi:application
I get this error:
2014-03-17 19:11:54 [30703] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
worker.init_process()
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
self.wsgi = self.app.wsgi()
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
self.callable = self.load()
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
return self.load_wsgiapp()
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
import(module)
ImportError: No module named wsgi
Traceback (most recent call last):
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
worker.init_process()
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
self.wsgi = self.app.wsgi()
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
self.callable = self.load()
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
return self.load_wsgiapp()
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/lamr/uber-clay/venv/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
import(module)
ImportError: No module named wsgi
I'm guessing it's because I dont have a clay.wsgi file.
I found this for flask
http://flask.pocoo.org/docs/deploying/mod_wsgi/#creating-a-wsgi-file
but creating a clay.wsgi with this inside
"from clay import app as application"
didn't change the error code.
Does anyone have experience moving Clay to production?
Thanks for your help!
Hi @JeremyGrosser - Can you add me (username: datoug) to the admin of the clay-flask package in pypi, so that I can publish a new version?
Thanks.
How do I do data driven test in clay?
I tried using pytest's parameterize but doesn't seem to work with clay.
So in the infraportal configuration, you have SECRET_KEY set inside flask.config, but I think server.py will overwrite that with None.
https://github.com/uber/infraportal/blob/4baf729702fb4c05be487cfc5e25874b5c740ff0/infraportal-prod.conf#L8
https://github.com/uber/clay/blob/master/clay/server.py#L35
I think the way infraportal does it is best as it mirrors "standard" flask apps better. I think you could just delete line 35 or at least change it to not do anything if the secret key is already set.
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.