-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python API for QueueValue is not implemented #2743
Comments
|
Okay, I have to withdraw my previous (deleted) comment, unfortunately (I had a typo in the code) - while it is possible to create Values in a unified way in |
Actually while we're at it: what is a Edit: okay, skimming through the code it seems the "LinkValue" is like Link<Value> - which makes more sense when looked at this way (still will be confusing for new people). |
Okay, the example went back to returning |
@ntoxeg , as @linas said it should be enough to add: # For handling the children types of LinkValue.
if is_a(value_type, types.LinkValue):
return LinkValue(ptr_holder = ptr_holder) before atomspace/opencog/cython/opencog/nameserver.pyx Lines 83 to 89 in 77c997b
But I don't see why you are talking about |
I think so. |
It's correct if the query is meant to return no results. QueueValue is a thread-safe FIFO -- multiple writers in multiple threads can write to it, multiple readers in multiple threads can read from it, and it will stay consistent. It is used to accumulate search results, as they are found. A LinkValue is just a holder of multiple values. It's not thread-safe. Streams are values that change over time -- so a LinkStream is a LinkValue whose contents may or may not change over time. Whether or not its thread safe, or how it might work, depends on what kind of stream it is. i.e. its implementation-dependent on the particular stream. Besides queues, other examples of streams might be video and audio ... does not mean that we actually store video and audio in the atomspace; merely that they can be sampled whenever needed, or otherwise operated on, e.g. with PlusLink to e.g. combine two audio streams, etc. |
and .. ohh... BTW, @vsbogd I should mention -- since we're on the topic -- not only can you apply a PlusLink to two audio streams (if we had audio streams, which we don't) one should be able to do the same for neural net values or tensorflow, etc. So if you had (for example) some Or maybe instead, if you wanted to specify some particular set of processing steps (like what tensorflow does) you could say, for example, "I want to combine net A B and C", you could use PlusLink for that. Or maybe some other There's a working example of this, using |
It would be convenient if
You probably mean stream.scm example? |
I would also mention @noskill here. |
Propose one. As a general rule, I try to under-design/under-specify brand-new interfaces and brand-new ideas. That way, I can avoid adding bad/broken/poorly designed API's in the early stages. The correct/best API "materializes out of thin air" with the first 2 or 3 "practical applications" when it becomes clear how it should have worked. The down-side of under-design is that handy utilities are missing in the early stages. They have to be added...
The "stream" here would be a stream of LinkValues. If you just want a stream of any kind of values, the base class would be
But |
err... or not. Some confusion here. Need to clarify this, per #2750 |
Saying "wait" I mean be notified when next value appears in the stream. It is not necessary blocking but it allows user of the Nevertheless one could use it to rewrite example above as something like: query_link = MeetLink(VariableNode("$test"), MemberLink(VariableNode("$test"), ConceptNode("Constant")))
result2 = execute_atom(atomspace, query_link)
result2.update()
print("results:", result2.to_list()) |
I see in code that |
The
There are three styles of notification: blocking until some action is done, polling in a loop The current QueueValue is a combo of several parts: a thread-safe FIFO plus some quick hacks. The thread-safe FIFO does what you want. The quick hack then hides it in backwards-compatible junk. So, the old, and still current API to I did it this way because I wanted to have the multi-threaded capabilities in place and ready to be used, but didn't want to break backwards-compat. The problem is that almost no one cares, so I wasn't going to go through contortions and complete exhaustion to carefully design something that no one cares about and no one will use. So the fancy threads and queues are hidden, for now. However, if you are ready to use this, then the next step would be to write a multi-threaded demo, showing how to start the BTW, cogutils has three things: a concurrent FIFO, a LIFO (last-in, first-out aka a "stack") and a de-duplicating set (arbitrary order; duplicates are auto-removed/ignored). The all have two modes: "open", where you can add/remove items, and "closed", where no more items can be added, indicating that the work is "done". Because FYI, there is also |
I see that query_link = MeetLink(VariableNode("$test"), MemberLink(VariableNode("$test"), ConceptNode("Constant")))
result2 = execute_atom(atomspace, query_link)
print("results:", result2.to_list()) |
Yes. Values are still sort-of experimental-ish. I'm not entirely happy with having std:vector in them by default, and having |
The following code returns an error:
the output:
The text was updated successfully, but these errors were encountered: