How To Dynamically Create ViewFlow Processes? - django-viewflow

I'm trying to set up a service so that a user could feasibly build their own workflows through a GUI or otherwise easy-to-use interface.
When I try anonymously creating nodes and then referring to them by their position in a list, I get stuck - this.nodes[0] (where nodes is the list storing the anonymous nodes) fails because "this" isn't iterable, this.(nodes[0]) is invalid syntax, and nodes[0] (sans this) returns a NoneType object.
How can I go about dynamically generating nodes?

There is no such functionality in the Viewflow.

Related

Can we capture live object of one program into another program?

If suppose we have a program1 inside that we are creating one object.
Now we have one object.
In the second program can we capture this object with out again instantiate,
Assume that program1 is still running and object is alive.
Actually we are using python celery, this always running and object is alive which i was created inside the code. my aim to capture that live object into another program.
is it possible?
Short Answer: kind-of.
Long-answer: you can't ever get "live objects" in a distributed environment unless you are doing something like CORBA. Instead, anytime you use celery, you are serializing objects onto and deserializing objects from a broker. Similarly, you can serialize return values as objects into the results backend. So, you can have celery serialize python objects by using the pickle serializer. But, in no circumstance will you get a live object. Instead, what you will be getting is your own copy of the object that Celery was working on.

Hazelcast Entry Processor: When objects affect objects in other maps

My example use case:
I have an IMap with an old membership list (where members' addresses are stored as attributes of the member-object) and an IMap with valid addresses from an alternate member list. I know that my old member IMap has older information and the alternate address list has up-to-date address information (such as 4 digit zip code extensions).
I want to visit each member entry in the old member IMap and create a new address-object from the member-object. Each unique address will eventually be stored in a database, so I don't want duplicate address objects. I want to store each unique address in an IMap of valid addresses.
If I iterate over the old member IMap I get a Class Not Found exception when I try to put new address object into the new valid-addresses IMap.
If I'm creating new objects while visiting objects in one IMap, how do I collect them in another IMap?
Entry Processors are intended to work only on the entry they're submitted to (the target of the executeOnKey() method). This allows for a number of optimizations, as the entry processor runs on an operation thread dedicated to the partition holding the data. If the Entry Processor was to access data in another partition, locks would be required and there is the possibility that a deadlock could occur. If the other entry was on a different cluster node, this could adversely impact performance of the Entry Processor which should be a quick operation.
The executeOnKey method returns an Object; you could code your Entry Processor to return the new address object, and the client could then put this object to the appropriate map (which might be on a different cluster node).
This is also something that might be appropriate for Hazelcast Jet; Jet could use one map as a source and the other map as a sink and perform the appropriate operations as part of its pipeline.
The correct way to deal with this situation (effecting items in a second map) is to use an EventListener.
I implemented an EventListener for the old members map that adds an address-object to the address map if it doesn't already exist, whenever a member in the old members map is updated.
Jet does seem like a great way to deal with exactly this kind of process model, but I haven't implemented it yet to verify how it works in my use case.

How can I have a Map that all processes can access?

I'm building a multithreaded web crawler.
I launch a thread that gets first n href links and parses some data. Then it should add those links to a Visited list that other threads can access and adds the data to a global map that will be printed when the program is done. Then the thread launches new n new threads all doing the same thing.
How can I setup a global list of Visited sites that all threads can access and a global map that all threads can also write to.
You can't share data between processes. That doesn't mean that you can't share information.
the usual way is either to use a special process (a server) in charge of this job: maintain a state; in your case the list of visited links.
Another way is to use ETS (or Mnesia the database build upon ETS) which is designed to share information between processes.
Just to clarify, erlang/elixir uses processes rather than threads.
Given a list of elements, a generic approach:
An empty list called processed is saved to ets, dets, mnesia or some DB.
The new list of elements is filtered against the processed list so the Task is not unnecessarily repeated.
For each element of the filtered list, a task is run (which in turn spawns a process) and does some work on each element that returns a map of the required data. See the Task module Task.async/1 and Task.yield_many/2 could be useful.
Once all the tasks have returned or yielded,
all the maps or parts of the data in the maps are merged and can be persisted if/as required/appropriate.
the elements whose tasks did not crash or timeout are added to the processed list in the DB.
Tasks which crash or timeout could be handled differently.

Using Google map objects within a web worker?

The situation:
Too much stuff is running in the main thread of a page making a google map with overlays representing ZIP territories coming from US census data and stuff the client has asked for grouping territories into discreet groups. While there is no major issue on desktops, mobile devices (iPad) decide that the thread is taking too long (max of 6 seconds after data returns) and therefore must have crashed.
Solution: Offload the looping function to gather the points for the shape from each row to a web worker that can work as fast or slow as resources allow on a mobile device. (Three for loops, 1st to select row, 2nd to select column, 3rd for each point within the column. Execution time: matter of 3-6 seconds total for over 2000+ rows with numerous points)
The catch: In order for this to be properly efficient, the points must be made into a shape (polygon) within the web worker. HOWEVER since it is a google.maps.polygon object made up of google.maps.latlng objects it [the web worker] needs to have some knowledge of what those items are within the web worker. Web workers require you to not use window or the DOM so it must import the script and the intent was to pass back just the object as a JSON encoded item. The code fails on any reference of google objects even with importScript() due to the fact those items rely on the window element.
Further complications: Google's API is technically proprietary. The web app code that this is for is bound by NDA so pointed questions could be asked but not a copy/paste of all code.
The solution/any vague ideas:???
TLDR: Need to access google.maps.latlng object and create new instances of (minimally) within a web worker. Web worker should either return Objects ready to be popped into a google.maps.polygon object or should return a google.maps.polygon object. How do I reference the google maps API if I cannot use the default method of importing scripts due to an issue requiring the window object?
UPDATE: Since this writing Ive managed to offload the majority of the grunt work from the main thread to the web worker allowing it to parse through the data asynchronously and assign the data to custom made latlng object.
The catch now is getting the returned values to run the function in the proper context to see if the custom latlng is sufficient for google.maps.polygon to work its magic.
Excerpt from the file that calls the web worker and listens for its response (Coffeescript)
#shapeWorker.onmessage= (event)->
console.log "--------------------TESTING---------------"
data=JSON.parse(event.data)
console.log data
#generateShapes(data.poly,data.center,data.zipNum)
For some reason, its trying to evaluate GenerateShapes in the context of the web worker rather than in the context of the class its in.
Once again it was a complication of too many things going on at once. The scope was restricted due to the usage of -> rather than => which expands the scope to allow the parent class functions.
Apparently the issue resided with the version of iOS this web app needed to run on and a bug with the storage being set arbitrarily low (a tenth of its previous size). With some shrinking of the data and a fix to the iOS version in question I was able to get it running without the usage of web workers. One day I may be able to come back to it with web workers to increase efficiency.

Populating a ListView in a multithreaded app

I need to retrieve a set of data from a database, then populate a ListView with the data. I understand multithreaded form controls and the proper techniques for updating controls from worker threads. Here's the dilemma:
I may have several thousand entries in the ListView... rather than Invoking the form thread to update them one at a time, I'd like to build a collection of ListViewItem objects and use ListView.Items.AddRange(ListViewItemCollection).
However, the MSDN documentation advises not to create your own ListViewItemCollection (and indeed, trying to create my own ListViewItemCollection generates a null reference error because there's no parent set). Instead, MS recommends that you only work with a ListViewItemCollection by getting it via the ListView.Items property.
Which, of course, is circular reasoning and can't be done from a worker thread without generating an error: "Cross-thread operation not valid: Control 'ListView' accessed from a thread other than the thread it was created on."
I could use the overloaded AddRange(ListViewItem[]), but arrays are rather clunky in this day and age.
Anyone have a suggestion how to add several thousand items to a ListView from a worker thread?
I think you already have your answer - AddRange(ListViewItem[]). If you find arrays distasteful, you can use a List and then do a toArray() right when you call AddRange.

Resources