Why is Kinto using Cliquet and what is the difference between the two ?
Disclaimer: I am one of the authors of both tools. Since this is frequently asked question, I thought it would be relevant to share a proper answer here :)
At Mozilla Services we regularly implement and deploy micro-services.
Since most services share the same production requirements (in terms of monitoring, REST protocols etc.), we decided to develop and package a reusable toolkit using Cornice.
Kinto is one of those services. It uses Cliquet as one of its core libraries.
The Kinto HTTP API is made of several REST endpoints, that all share a set of common properties (filtrable, sortable etc.). The common code base for those REST resources is implemented as a reusable class in Cliquet.
We really like the name Cliquet. However, given the confusion of its scope, we will probably (some day) split it into two packages, called like cornice-mozprod and cornice-crud.
Kinto and Cliquet have now be merged together, and cliquet is no longer a thing.
See all the nifty details at https://mail.mozilla.org/pipermail/kinto/2016-May/000119.html
Related
I hope you are feeling good and safe.
I'm working on Natural language processing project for my master degree, and I do need to translate
my local dialect to ENG, and I noticed that Facebook translate machine did very well with my local dialect.
So my question is there any way to use Facebook translate service in my project, like is there any api or python module that use it.
Which language is your local language?
Facebook has many machine translation models, so it depends on how good it has to be and how much computing power you have. I am not sure if they offer their latest state-of-the-art ones that they use in their products as an independent translation tool as well.
First Option: Run full models locally
One way would be using one of their models on huggingface (see the "Generation" part):
https://huggingface.co/docs/transformers/model_doc/m2m_100#training-and-generation
They also have some easy-to-use pretrained models in their torch.hub module (but that probably doesnt cover your local language):
https://github.com/pytorch/fairseq/blob/main/examples/translation/README.md
Second Option: APIs
As I said it depends on what quality you need, you could try out some easy-to-use (non-facebook) APIs and see how far that gets you, as this is much easier and you can use them online:
e.g. https://libretranslate.com/
Or check out this comparison of APIs: https://rapidapi.com/collection/google-translate-api-alternatives
APIs are usually limited to a maximum number of characters/words/requests per month/day/minute so you'll have to see if that is enough for your case and if the quality is acceptable.
Third Option: pip packages which use APIs
For example check out: https://pypi.org/project/deep-translator/
Fourth Option: pip wrapper packages which run translation locally
A great package which actually has some pretty strong facebook MT models is: https://pypi.org/project/EasyNMT/ (it also has their strong m2m_100 models)
More lightweight but probably not as strong: https://github.com/argosopentech/argos-translate
Conclusion:
Since I assume your local language is not supported by that many models I would first try the fourth option (start with biggest models and if it doesnt work try smaller ones).
If that doesnt work out you can try if you can get APIs work for your case.
If you have a lot of computing power and want to go a bit deeper you can run the full model inference locally using huggingface or fairseq.
For working with data from a database inside of Python programmes, we generally use Object Relational Mappers, to translate database entries into python objects we can work with, with sqlAlchemy and Django Models probably being the most common and advanced ORMs.
Are there ORMs that do not connect to a database but to a third party (JSON) REST API instead? I would like to have a framework which lets me deal with Python objects to perform CRUD operations on the API. This should have all the well-established standard functionalities of an ORM, including Unit of Work and Lazy Loading. Actually, I would want my python code to be agnostic about whether the model is stored in a database or being fetched from a third party API.
It is hard for me to imagine that such a thing does not yet exist. But I am not able to find it. Maybe I am not knowing the right words to search for it?
ORMs Frameworks are frameworks that connect to databases. From your description you are talking about a DAO pattern, not about a Framework. This is a common programming pattern in other languages such as Java.
The right words or searches would be:
Search for the DAO pattern, what to expect from it and how to code it.
Check a couple of links on examples of DAO patterns in python such as this one, or this other one
Analyze your specific problem. You might not need all the code other solutions offer you. And you might be better off coding yourself your own class adjusted to your needs.
Remember KISS and DRY.
PS: Different languages use different paradigms, it is a common error to try to extrapolate patterns and coding uses from one language to another. So something that is solved in e.g. Java in a way, might not be the best option for Python. Keep that in mind too.
The site won't be that complicated and will resemble a modern blog (users, messages, news and other similar features).
Do I need to use a framework for this, and if so, which is best?
Pyramid, Django?
You certainly don't need a webframework to create a simple website. Given that you're new to python and interested in building a python website, I imagine this implies: you're interested in learning python. If you're exclusively interested in learning django-python, there's no reason you can't jump in to django, as Ronak said, of course. He's right. It has a lot of documentation. But it will make for somewhat of an odd intro to python.
If I were in your shoes, I'd either start making some offline programs first, or consider an ultra-lightweight framework. Many would advocate web2py or pyramid for ultralightweight. I might consider going even lighter. Something like Bottle, where you're more or less just pairing functions with urls. This way you can at least do a bit of hacking/trial-and-error, instead of launching right into django.
It's not that django doesn't use python-- it will tell you many times that it is in fact 'just python.' But it's adapted at its core to be used in a large business setting (the chicago something or other online, i think). So it enforces various rules that are helpful in managing many different employees working on a project together. You may or may not wish for this kind of 'help.' It also means the scale of projects is assumed to be large and the time-horizon, limitless. If you want to see how a python dictionary works, you may not want to spend a long time configuring settings and creating the pseudo-static-typing you need for your database, and so on, just to execute your project and see a result.
I realize I will automatically get downvoted for this, but I believe it to be sound advice.
It depends on what kind of website you are planning to come up with. If the website is going to be just a set of static HTML files, then you don't really need a framework. But if your website will have lots of dynamic content that will get updated on regular basis, you should go with some framework. That will make your life maintaining the website much more simpler.
Django is the most popular framework written in Python. It has very good documentation and a strong community base too.
Go with Django - 10,000 Elvis fans can't be wrong.
Or roll your own from scratch. You'll learn a lot, know everything about how you site works, and better appreciate what a framework does for you.
As RonakG first pointed, it all depends on the kind of website you intend to have up and running. Actually, your question is too general for a single, definitive answer. There are more aspects to consider other than just being in python. For example, deadlines. This means considering the learning curve to achieve your results. If you don't have much time, a steep learning curve (time to learn it in order to develop it) is certainly something you will want to avoid. Perhaps you already develop in other languages, and need integration and/or migration support, need scalability, reusability, etc, etc, etc.
Another thing that is not so clear in your question is what you mean by "The site won't be that complicated and will resemble a modern blog (users, messages, news and other similar features)". If it really resembles just a modern blog, with users, messages and news, you could google for CMS (Content Management Systems). There are many options available, that could make you have your site up and running in almost no-time. All you'll have to learn is how to customize whatever it has to as to comply to your needs.
That said, if you prefer python, there are some good CMSs available which you can develop your site fast, like Plone. And if you prefer Django, there's Django CMS and there's the excellent Pinax project, which takes the django code reusability to deliver you sample fully customizable, complete websites.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm comming from java world (apache wicket) and need to use python for my project.
I've heard about Turbogear2, Pyramid(Pylons) or Django and read some about them.
My first choice will be TurboGears2 built on top of Pylons, with tools already packaged, but
perhaps someone as some advice.
I do not need to create a lot of content like wikis or blog, but represent and
give access to some objects in my database, and then build a javascript interface
to work on this data.
What I need the web framework to to for me :
authentication system with roles (admin, user, group,...)
use of enhanced javascript tools like dojo outside the app, but
it would be good if I could share components between the app and the javascript library.
easy AJAX : components have to be refreshed 'onChange' (I don't like submit buttons)
a good ORM. Don't know SQLAlchemy but it seems nice, mapping object to/from database, database pooling,....
easy deployment (coming from java I think it will be ok ;))
add easily css or js to pages
a framework that don't break my nerves ;)
a good documentation and/or good support
threading/multiprocess support (there are a lot of calculations. Some of them taking huge amout of memory, some other taking
processing time. So I want to be able to lauch procees out of application. But I think it's more about using a python library
and nothing to do with this question? )
THX
For myself, mako + sqlalchemy in Pyramid are what seal the deal. If you're into some decent DB work, SqlAlchemy is just the best to work with. I'm also a big fan of the mako templates. The ability to create presentation type functions in mako itself that are reusable vs trying to do things in python modules that you end up trying to import in is a plus in my book.
What I really wanted to mention is that for your final item, you should really look at farming that stuff out to outside workers by using a message queue and something like Celery to do the work and use the web app more for submission/results display than actually trying to split the work out of your web application.
As pointed out by S.Lott in his comment, your requirements do not give a clear-cut "winner" as at least most of the frameworks have that capability.
Three dimensions along which which python web framework diverge more are IMO:
Closeness to the concept of "pythonic"
Lightness
Overhead
Typically lighter frameworks will: require more overhead and have a more pythonic approach (webpy, cherrypy...), while heavier frameworks (django, turbogear...) will let you have your app up and running in minutes but will somehow oblige you to shape your code in a certain (logical but not necessarily pythonic) way.
That said, I believe 95% of your answer relies on personal preference.
HTH!
In addition to the frameworks you have mentioned, you should definitely check out web2py. I think you'll find it among the easiest to set up, learn, and use, particularly given the breadth of functionality it offers. One if its primary goals is to not "break your nerves." It includes an excellent authentication system; integrated Javascript/AJAX support (see also components); a fast and powerful database abstraction layer; web services; automatic RESTful API generation; great documentation; and a very helpful and responsive mailing list. Development is very active, with new releases at least every month (without ever breaking backward compatibility). Here is a recent presentation.
An opinion piece...
I like the character of Pylons (now replaced by Pyramid) and the wide support of new initiatives by the Django framework (though not its keeness to reinvent so many wheels - esp. MVC).
I like the Data Abstraction Layer in Web2py that enables deployment to Google's AppEngine. This was a key feature in making my decision. Web2py is RoR inspired which some may shirk but which I've appreciated and so far hasn't blocked any development path.
In the end having tried several frameworks I've used Web2py (using the offical book as reference). A great community with very fast response.
I am having to look into some code and consider working in a Python framework called Glashammer.
I know and love Django. I have some experience with Appengine native framework and Django on Appengine.
I'd like to know from you that have used one or more of those, how Glahammer compares and contrasts with others. What are there any Pros and Cons and what else do I need to be aware of.
I am highly biased, because I am the Glashammer author. But the pros for me are:
Werkzeug-based framework removes much of the boilerplate in creating Werkzeug based
applications
Easy pluggability and high flexibility: 2 levels of plugins, Appliances which are reusable components and Bundles which are behavioural
modifiers.
Well unit tested
Documentation is not bad (for an open source project)
Versus something like Django, I would just have to say "Werkzeug-based, with a nicer plugin framework."
Did I mention the code is beautiful like a glowing orb of ... (oh maybe this is subjective)
After a bit of googling (and finding your question:) and half an hour of reading docs and code I can say that
Glashammmer is great because it:
is well-documented;
is lightweight and very flexible;
provides almost everything to rapidly build a complex web app -- unlike Werkzeug itself;
does not suffer from NIH syndrome which is arguably the Django's greatest wart;
does not impose database-related libraries and thus supports whatever storage one could use from Python. Django only supports a number of relational databases and assumes you are happy with them. Of course you can drop Django ORM but this renders admin -- the Django's strongest point -- useless;
appliances are the best way to define views I've seen so far.
Galashammer is not so great because it:
has shorter development history and much smaller community than Django's, which leads to:
inevitably lower quality of core code, and
inevitably lower quantity of contributed code;
makes use of some components that may be unstable (e.g. flatland which is in alpha stage, though it's an arbitrary label and may be irrelevant to quality; moreover, it's only used in glashammer.utils.yconfig);
does not provide an API to define models (e.g. some declarative wrapper with backends), so the "pluginability" of applications can be significantly weaker that in Django (applications will make too many assumptions about the environment).
Anyway, I think this framework is worth diving into.