Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
Social Cognitive Systems
ipaaca
Commits
d1aa2b6f
Commit
d1aa2b6f
authored
10 years ago
by
Hendrik Buschmeier
Browse files
Options
Downloads
Patches
Plain Diff
Further simplified converters.
parent
dc5b5646
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ipaacalib/proto/ipaaca.proto
+1
-3
1 addition, 3 deletions
ipaacalib/proto/ipaaca.proto
ipaacalib/python/src/ipaaca/__init__.py
+1
-1
1 addition, 1 deletion
ipaacalib/python/src/ipaaca/__init__.py
ipaacalib/python/src/ipaaca/converter.py
+30
-59
30 additions, 59 deletions
ipaacalib/python/src/ipaaca/converter.py
with
32 additions
and
63 deletions
ipaacalib/proto/ipaaca.proto
+
1
−
3
View file @
d1aa2b6f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// "Incremental Processing Architecture
// "Incremental Processing Architecture
// for Artificial Conversational Agents".
// for Artificial Conversational Agents".
//
//
// Copyright (c) 2009-201
3
Socia
ble Agent
s Group
// Copyright (c) 2009-201
4
Socia
l Cognitive System
s Group
// CITEC, Bielefeld University
// CITEC, Bielefeld University
//
//
// http://opensource.cit-ec.de/projects/ipaaca/
// http://opensource.cit-ec.de/projects/ipaaca/
...
@@ -97,5 +97,3 @@ message IULinkUpdate {
...
@@ -97,5 +97,3 @@ message IULinkUpdate {
required
bool
is_delta
=
5
[
default
=
false
];
required
bool
is_delta
=
5
[
default
=
false
];
required
string
writer_name
=
6
;
required
string
writer_name
=
6
;
}
}
This diff is collapsed.
Click to expand it.
ipaacalib/python/src/ipaaca/__init__.py
+
1
−
1
View file @
d1aa2b6f
...
@@ -59,7 +59,7 @@ def initialize_ipaaca_rsb():
...
@@ -59,7 +59,7 @@ def initialize_ipaaca_rsb():
dataType
=
IU
))
dataType
=
IU
))
rsb
.
converter
.
registerGlobalConverter
(
rsb
.
converter
.
registerGlobalConverter
(
ipaaca
.
converter
.
IU
Converter
(
ipaaca
.
converter
.
Message
Converter
(
wireSchema
=
"
ipaaca-messageiu
"
,
wireSchema
=
"
ipaaca-messageiu
"
,
dataType
=
Message
))
dataType
=
Message
))
...
...
This diff is collapsed.
Click to expand it.
ipaacalib/python/src/ipaaca/converter.py
+
30
−
59
View file @
d1aa2b6f
...
@@ -92,89 +92,59 @@ class IUConverter(rsb.converter.Converter):
...
@@ -92,89 +92,59 @@ class IUConverter(rsb.converter.Converter):
'''
'''
def
__init__
(
self
,
wireSchema
=
"
ipaaca-iu
"
,
dataType
=
ipaaca
.
iu
.
IU
):
def
__init__
(
self
,
wireSchema
=
"
ipaaca-iu
"
,
dataType
=
ipaaca
.
iu
.
IU
):
super
(
IUConverter
,
self
).
__init__
(
bytearray
,
dataType
,
wireSchema
)
super
(
IUConverter
,
self
).
__init__
(
bytearray
,
dataType
,
wireSchema
)
self
.
_access_mode
=
ipaaca_pb2
.
IU
.
PUSH
self
.
_remote_data_type
=
ipaaca
.
iu
.
RemotePushIU
def
serialize
(
self
,
iu
):
def
serialize
(
self
,
iu
):
pbo
=
ipaaca_pb2
.
IU
()
pbo
=
ipaaca_pb2
.
IU
()
pbo
.
access_mode
=
self
.
_access_mode
pbo
.
uid
=
iu
.
_uid
pbo
.
uid
=
iu
.
_uid
pbo
.
revision
=
iu
.
_revision
pbo
.
revision
=
iu
.
_revision
pbo
.
category
=
iu
.
_category
pbo
.
category
=
iu
.
_category
pbo
.
payload_type
=
iu
.
_payload_type
pbo
.
payload_type
=
iu
.
_payload_type
pbo
.
owner_name
=
iu
.
_owner_name
pbo
.
owner_name
=
iu
.
_owner_name
pbo
.
committed
=
iu
.
_committed
pbo
.
committed
=
iu
.
_committed
am
=
ipaaca_pb2
.
IU
.
PUSH
#default
if
iu
.
_access_mode
==
ipaaca
.
iu
.
IUAccessMode
.
MESSAGE
:
am
=
ipaaca_pb2
.
IU
.
MESSAGE
# TODO add other types later
pbo
.
access_mode
=
am
pbo
.
read_only
=
iu
.
_read_only
pbo
.
read_only
=
iu
.
_read_only
for
k
,
v
in
iu
.
_payload
.
items
():
for
k
,
v
in
iu
.
_payload
.
iter
items
():
entry
=
pbo
.
payload
.
add
()
entry
=
pbo
.
payload
.
add
()
pack_payload_entry
(
entry
,
k
,
v
)
pack_payload_entry
(
entry
,
k
,
v
)
for
type_
in
iu
.
_links
.
keys
():
for
type_
in
iu
.
_links
.
keys
():
linkset
=
pbo
.
links
.
add
()
linkset
=
pbo
.
links
.
add
()
linkset
.
type
=
type_
linkset
.
type
=
type_
linkset
.
targets
.
extend
(
iu
.
_links
[
type_
])
linkset
.
targets
.
extend
(
iu
.
_links
[
type_
])
ws
=
"
ipaaca-messageiu
"
if
iu
.
_access_mode
==
ipaaca
.
iu
.
IUAccessMode
.
MESSAGE
else
self
.
wireSchema
return
bytearray
(
pbo
.
SerializeToString
()),
self
.
wireSchema
return
bytearray
(
pbo
.
SerializeToString
()),
ws
def
deserialize
(
self
,
byte_stream
,
ws
):
def
deserialize
(
self
,
byte_stream
,
ws
):
type
=
self
.
getDataType
()
pbo
=
ipaaca_pb2
.
IU
()
if
type
==
ipaaca
.
iu
.
IU
or
type
==
ipaaca
.
iu
.
Message
:
pbo
.
ParseFromString
(
str
(
byte_stream
))
pbo
=
ipaaca_pb2
.
IU
()
_payload
=
{}
pbo
.
ParseFromString
(
str
(
byte_stream
)
)
for
entry
in
pbo
.
payload
:
if
pbo
.
access_mode
==
ipaaca_pb2
.
IU
.
PUSH
:
_payload
[
entry
.
key
]
=
unpack_payload_entry
(
entry
)
_payload
=
{}
_links
=
collections
.
defaultdict
(
set
)
for
entry
in
pbo
.
payload
:
for
linkset
in
pbo
.
links
:
_payload
[
entry
.
key
]
=
unpack_payload_entry
(
entry
)
for
target_uid
in
linkset
.
targets
:
_links
=
collections
.
defaultdict
(
set
)
_links
[
linkset
.
type
].
add
(
target_uid
)
for
linkset
in
pbo
.
links
:
return
self
.
_remote_data_type
(
for
target_uid
in
linkset
.
targets
:
uid
=
pbo
.
uid
,
_links
[
linkset
.
type
].
add
(
target_uid
)
revision
=
pbo
.
revision
,
remote_push_iu
=
ipaaca
.
iu
.
RemotePushIU
(
read_only
=
pbo
.
read_only
,
uid
=
pbo
.
uid
,
owner_name
=
pbo
.
owner_name
,
revision
=
pbo
.
revision
,
category
=
pbo
.
category
,
read_only
=
pbo
.
read_only
,
payload_type
=
pbo
.
payload_type
,
owner_name
=
pbo
.
owner_name
,
committed
=
pbo
.
committed
,
category
=
pbo
.
category
,
payload
=
_payload
,
payload_type
=
pbo
.
payload_type
,
links
=
_links
)
committed
=
pbo
.
committed
,
payload
=
_payload
,
links
=
_links
)
return
remote_push_iu
elif
pbo
.
access_mode
==
ipaaca_pb2
.
IU
.
MESSAGE
:
_payload
=
{}
for
entry
in
pbo
.
payload
:
_payload
[
entry
.
key
]
=
unpack_payload_entry
(
entry
)
_links
=
collections
.
defaultdict
(
set
)
for
linkset
in
pbo
.
links
:
for
target_uid
in
linkset
.
targets
:
_links
[
linkset
.
type
].
add
(
target_uid
)
remote_message
=
ipaaca
.
iu
.
RemoteMessage
(
uid
=
pbo
.
uid
,
revision
=
pbo
.
revision
,
read_only
=
pbo
.
read_only
,
owner_name
=
pbo
.
owner_name
,
category
=
pbo
.
category
,
payload_type
=
pbo
.
payload_type
,
committed
=
pbo
.
committed
,
payload
=
_payload
,
links
=
_links
)
return
remote_message
else
:
raise
Exception
(
"
We can only handle IUs with access mode
'
PUSH
'
or
'
MESSAGE
'
for now!
"
)
else
:
raise
ValueError
(
"
Inacceptable dataType %s
"
%
type
)
class
MessageConverter
(
IUConverter
):
class
MessageConverter
(
IUConverter
):
'''
'''
Converter class for
Message
IU representations
Converter class for
Full
IU representations
wire:bytearray <-> wire-schema:ipaaca-
message
iu <-> class ipaacaRSB.IU
wire:bytearray <-> wire-schema:ipaaca-
full-
iu <-> class ipaacaRSB.IU
'''
'''
def
__init__
(
self
,
wireSchema
=
"
ipaaca-messageiu
"
,
dataType
=
ipaaca
.
iu
.
Message
):
def
__init__
(
self
,
wireSchema
=
"
ipaaca-messageiu
"
,
dataType
=
ipaaca
.
iu
.
Message
):
super
(
MessageConverter
,
self
).
__init__
(
wireSchema
=
wireSchema
,
dataType
=
dataType
)
super
(
MessageConverter
,
self
).
__init__
(
wireSchema
,
dataType
)
self
.
_access_mode
=
ipaaca_pb2
.
IU
.
MESSAGE
self
.
_remote_data_type
=
ipaaca
.
iu
.
RemoteMessage
class
IULinkUpdate
(
object
):
class
IULinkUpdate
(
object
):
...
@@ -199,6 +169,7 @@ class IULinkUpdate(object):
...
@@ -199,6 +169,7 @@ class IULinkUpdate(object):
class
IULinkUpdateConverter
(
rsb
.
converter
.
Converter
):
class
IULinkUpdateConverter
(
rsb
.
converter
.
Converter
):
def
__init__
(
self
,
wireSchema
=
"
ipaaca-iu-link-update
"
,
dataType
=
IULinkUpdate
):
def
__init__
(
self
,
wireSchema
=
"
ipaaca-iu-link-update
"
,
dataType
=
IULinkUpdate
):
super
(
IULinkUpdateConverter
,
self
).
__init__
(
bytearray
,
dataType
,
wireSchema
)
super
(
IULinkUpdateConverter
,
self
).
__init__
(
bytearray
,
dataType
,
wireSchema
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment