-
Notifications
You must be signed in to change notification settings - Fork 8
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
C handle init #76
C handle init #76
Changes from 12 commits
679bd66
66a258f
d6847b4
23a6d2c
9de0708
a2bc598
6c95a5c
4172f01
bb8f737
14c1e77
8c0e639
5fa9f76
7f30f42
ce8cf15
3f77ed4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1392,11 +1392,13 @@ def message_id(self, v): | |
|
||
|
||
class HelicsQuery(_HelicsCHandle): | ||
pass | ||
def __init__(self, handle, cleanup=False): | ||
super(HelicsQuery, self).__init__(handle, cleanup) | ||
trevorhardy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class HelicsQueryBuffer(_HelicsCHandle): | ||
pass | ||
def __init__(self, handle, cleanup=False): | ||
super(HelicsQueryBuffer, self).__init__(handle, cleanup) | ||
trevorhardy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class HelicsEndpoint(_HelicsCHandle): | ||
|
@@ -2823,7 +2825,8 @@ class HelicsCallbackFederate(HelicsCombinationFederate): | |
pass | ||
|
||
class HelicsDataBuffer(_HelicsCHandle): | ||
pass | ||
def __init__(self, handle, cleanup=False): | ||
super(HelicsDataBuffer, self).__init__(handle, cleanup) | ||
trevorhardy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class HelicsException(Exception): | ||
|
@@ -7269,7 +7272,7 @@ def helicsTranslatorGetName(translator: HelicsTranslator) -> str: | |
|
||
**Returns**: A string with the name of the translator. | ||
""" | ||
f = loadSym("helicsPublicationGetName") | ||
f = loadSym("helicsTranslatorGetName") | ||
result = f(translator.handle) | ||
return ffi.string(result).decode() | ||
|
||
|
@@ -9364,7 +9367,8 @@ def helicsQueryBufferFill(buffer: HelicsQueryBuffer, string: str): | |
""" | ||
f = loadSym("helicsQueryBufferFill") | ||
err = helicsErrorInitialize() | ||
f(buffer.handle, string, len(string), err) | ||
str_ptr = ffi.new('char[]', string.encode('utf-8')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is HELICS expecting a utf-8 encoded string? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what Mark Eberlein put in and it works so I guess, "yes"? It might make more sense to choose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the test code in HELICS is just shoving a regular There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @phlptp; any input on what you think we should do here? I don't have a philosophical problem with supporting data structures (raw bytes) as query responses if there's a need to do so BUT I suspect restricting this to ASCII or UTF-8 will make it easier to maintain the code and easier for users to understand what they are doing. Off the top of my head, I can't think of a use case where it would be important to support a raw bytes data structure where something like JSON wouldn't also be sufficient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I would be fine restricting it in python. In the lower levels there are a few use cases for queries/commands getting raw binary data that I want to leave open, but that would be really complicated to use in python so don't really think we would need to support it, and if someone wanted and had the ability they could directly access the library calls. |
||
f(buffer.handle, str_ptr, len(string), err) | ||
if err.error_code != 0: | ||
raise HelicsException("[" + str(err.error_code) + "] " + ffi.string(err.message).decode()) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having
pass
should be equivalent to these lines, so I'm not quite sure why this change is needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we just had
pass
in there we were getting the error below.Calling the super's init() solved the problem. Generally, I didn't think a class calls it's super's init but you know WAY MORE about these things than I do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're interested @kdheepak , I'm sure we can set up a call to go over this. Or, you can try running the connector example with and without the above changes to capi.py to see if you get similar behavior. You'll need to build the HELICS "dev" branch to get the connector app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HELICS 3.5 was released, so there should be a pre-built copy of the connector app available now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Github update automatically or manually? Right now it's showing v3.4.0 as the latest release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apparently have to actively select a check box for that now, now 3.5 should be the latest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still seeing the checkbox selected by default when I go to draft a release. It might remember the last selection that was made for a release.
I figured it just hadn't been marked as latest while the remaining interfaces were being updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is telling me that
buffer
is acdata 'void *'
object and has no attribute 'handle'.That's being called in:
pyhelics/helics/capi.py
Lines 9595 to 9609 in 5516142
You can see that
buffer
should be aHelicsQueryBuffer
and not acdata 'void *'
. That's telling me that the wrong data is being passed in for some reason.I do see the
HelicsQueryBuffer
is being created correctly here:https://github.com/GMLC-TDC/HELICS-Examples/blob/main/user_guide_examples/advanced/advanced_connector/interface_creation/Charger.py#L169
https://github.com/GMLC-TDC/HELICS-Examples/blob/main/user_guide_examples/advanced/advanced_connector/interface_creation/Battery.py#L116
I'll try to run the example to see what is going on when I get the chance.