Package: mishmash-io-client
mishmash iomishmash iois a distributed and scalable database that allows you to easily implement smart, predictive features in your app.Find out more onmishmash.ioAbout this packageThis is themishmash ioclient library for Python. Use it to connect, store / fetch data and to submit your algorithms for distributed execution.InstallingUsing Mishmash io in Heroku with jwt authentication plugin please install$pipinstallmishmash-io-client["jwt"]UsageTo be able to work with mishmash client you need to provide the following configuration as environment variables or as json file :for mishmash-io-auth-jwt pluginMISHMASHIO_SERVERS - list of mishmash servers endpointsMISHMASHIO_APP_ID - id of the app using mishmash clientMISHMASHIO_AUTH_SERVER - the identity provider server endpointMISHMASHIO_AUTH_PRIVATE_KEY - Private key used for authentication with the identity providerfor mishmash-io-clientMISHMASHIO_AUTH_METHOD - must be set to "jwt"MISHMASHIO_USE_SSL - True if you want to use ssl connectionUsing Mishmash in Azure cloud please install$pipinstallmishmash-io-client["azure"]Using Mishmash in Aws cloud please install$pipinstallmishmash-io-client["aws"]Using Mishmash in Google cloud please install$pipinstallmishmash-io-client["google"]Initializing the clientImport and create a new instance of Mishmash:fromMishmashimportMishmashmishmash=Mishmash()(make sure the lib can find its config)The mishmash variable now holds the 'mishmash of all data' for the given application. Everything stored inmishmash iois now accessible through that variable.What is a mishmash of data?A 'mishmash' is a special type of object that represents all or parts of the application data. It is, usually, acontainer, acollection, alist(a collection that has order) and aset(a collection where operators like 'union', 'intersection', etc can be applied).A mishmash can also represent a single Number, bool, string or other type of value.We call it a 'mishmash', because it just 'holds' data structures of arbitrary complexity - objects, lists, etc; types - mishmashes can 'hold' at the same time, for example - user profile objects and lists of their videos, posts, comments and so on. In other words - they 'hold' all the input that is needed for a particular application code to operate on.It's the responsibility of this application code to properly interpret each element and its meaning for the application; other objects in its context; and so on. With this in mind - mishmashes give the developer, an easy way, with little code - to describe input and apply complex logic on it.What a mishmash isn'tA 'mishmash' is not a table, has no rows, no columns, no cells. It has no specific data format, schema or structure on its own.It is application variables, stored.Using mishmashesA mishmash can be 'built' from literals, variables, code and other mishmashes. It can be assigned values and data; it can be deleted, updated, added to and deleted from. Code can be applied to mishmashes too.Mishmash objects are basically descriptors of data and not the actual data. Operations (accessing, indexing, 'union', etc) applied on a mishmash usually return another mishmash (another descriptor), and do not transfer data. This is called 'building a mishmash' - building the descriptor for data that will be needed by some application code later.Fetching data or results actually happens only when specifically requested (usually by the interpreter), for example - when a value is needed for a local computation, an iteration over the mishmash is requested in local code. These are often referred to as 'terminal operations' - building stops and transferring of data begins. More about terminal operations (and local vs remote code) below.Mutating the data (for example - storing new data, deleting existing data, etc) is done through assignments, additions, etc to a mishmash that has been built.Building a mishmashAll mishmashes are built from existing mishmashes or from the 'all data mishmash' (shown at the begining). As any building operation on a mishmash always returns a new mishmash - you can build one in several steps, iteratively or directly.Three major rules apply on all building operations on a given mishmash:Naming (or indexing) makes a more specific mishmash, e.g. when 'naming'videoson theusermishmash, like inuser.videos- the returned mishmash is more specific - 'holds' thevideosnow. Similarly, doinguser.videos[3]is even more specific.Enumerating (or listing) produces a broader mishmash -user['video', 'music']will return a mishmash of all music and videos. Enumerating is usually done by the commas (',') in your code."Code does" - applying code, by specifying a lambda, or a function or method - performs the action specified in the code on the mishmash that it is applied to. And it does that remotely - on themishmash iocluster (see below for more about 'local code' and 'remote code')These three rules can be mixed, combined and nested many times -my_mishmash[(age: [18:], department: 'software development')]func_has_birthday.Important:All three operations are done either as function call arguments -my_mishmash()or as item access (abracket notation) -my_mishmash[]. Naming can also be done by accessing a local attribute (adot notation) on a mishmash:my_mishmash.videos.Naming and indexingJust like accessing an attribute of an object by its name (or identifier) returns one of the specific values contained in that object, or accessing the element of a list located at a given index returns that one value among all others in the list - in the same way, 'naming' or 'indexing' a mishmash returns a mishmash that is describing a more specific subset of the initial data.In Python, this is done by using:dot notation- likemy_mishmash.age;singleint, float, bool, None, etcor other simple type -my_mishmash[4]ormy_mishmash(4);date, datetimeand similar;strorunicode-my_mishmash['age']ormy_mishmash('age');bytes, bytearray, memoryviewOr by using types that naturally contain names:namedtuplemappingobjects, likedict- {'age': 42, 'department': 'software development'}, dict(age: 42, department: 'software development')function call arguments with names:my_mishmash(age=42)And some of the sequence types that are often used as list indexes:rangesliceFinally, objects of other complex classes:another mishmashuser-defined classes (see below how these are treated)Python code - Callables - lambdas, functions, methods, generators, etc. (see below)EnumeratingA 'broader' mishmash - one that combines many 'deeper' mishmashes together into a whole, is created by enumerating multiple items. Or in other words - by supplying sequences or collections with no specific naming, mapping or other association between items.Simplest ways to create broader mishmashes in Python are:multiple function call arguments -my_mishmash('age', 'software development', my_other_mishmash)listortuple-my_mishmash[('software development', 'quality assurance')]set-my_mishmash({'software_development', 'quality assurance'})other, user-definediterableclasses (see below how user-defined classes are handled)Note:Callable code - like generators for example - are not considered as 'enumerating' parameters, they're handled as code - transferred to the cluster and optimized. This is because executable code can be doing much more than just enumerating. For this reason, it's considered on its own. (See below)Adding codeUsually you do not want to download all the data you have 'selected' with mishmash object.
For that reason mishmash gives a way to process selected data on the server side and get only the end results from processing.If you have a built mishmash you can submit a function or callable code to the mishmash server which defines an operation
over selected data. That piece of code will be optimized and run in parallel on the mishmash server instead of running locallyTODO add text for server side optimizationMore ways to build a mishmashCheck outmishmash.iofor more recent version of this document.Set operatorsYou can use bitwise set operators & and | over mishmash objectLooping on a mishmashGiven that a mishmash variable always represents a mishmash of data (or a set) -
looping on it should have the effect of 'pull those elements from the server and use them'.Mutating a mishmashYou can 'mutate' given mishmash - send local data or python code to the server
change or store and store them for future usageComputing with a mishmashCheck outmishmash.iofor more recent version of this document.Computing locallyCheck outmishmash.iofor more recent version of this document.Computing remotelyCheck outmishmash.iofor more recent version of this document.MoreCheck outmishmash.iofor more recent version of this document.Custom classesCheck outmishmash.iofor more recent version of this document.Serializing a mishmash for storage or transferCheck outmishmash.iofor more recent version of this document.