Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in
beat.backend.python
beat.backend.python
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 5
    • Issues 5
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • beat
  • beat.backend.pythonbeat.backend.python
  • Issues
  • #31

Closed
Open
Opened Mar 23, 2020 by Samuel GAIST@samuel.gaist
  • Report abuse
  • New issue
Report abuse New issue

Support bytes python type

Currently there's no way to send bytes directly from one algorithm to another.

The current "workaround" is to build the bytes output then use base64 encoding, use a string based type to write the data to the output and on the other end load it back from string.

Example of working code:

Output:

    obj = dict(field1=data.value*2, field2=data.value)
    dumped = pickle.dumps(obj)  # binary
    encoded = base64.b64encode(dumped)  # base64 bytes
    string = encoded.decode("ascii")  # "stringified"
    outputs["out_data"].write({"value": string})

WARNING Do not call str(encoded), it won't be a "real string":

example = b"whatever"
example_str = str(example)
example_str
#  output is "b'whatever'"

Input:

    in_data = inputs["in_data"].data  # string data
    decoded = base64.b64decode(in_data.value)  # decode to bytes
    obj = pickle.loads(decoded)  # obj is a dict and can be read

This issue tracks the implementation of the support for the python bytes type.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
1
Labels
enhancement
Assign labels
  • View project labels
Reference: beat/beat.backend.python#31