Skip to content
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

Fix ConsoleMessage Datetime for betterproto 2.0.0b7 #2815

Merged
merged 9 commits into from
Sep 5, 2024

Conversation

bobbai00
Copy link
Collaborator

@bobbai00 bobbai00 commented Sep 2, 2024

This PR fixes the error of python udf stuck when betterproto is at version 2.0.0b7

This fix is compatible with betterproto 2.0.0b3 to 2.0.0b7.

The cause of the bug

When betterproto is at version 2.0.0b7, timestamp requires the timezone information. Otherwise, there will be exceptions if print statements are in the python udf's code.

Before the fix, here is the code snippet of creating ConsoleMessage in pytexera:

ConsoleMessage(
                        worker_id=self.context.worker_id,
                        timestamp=datetime.datetime.now(),
                        msg_type=ConsoleMessageType.DEBUGGER,
                        source="(Pdb)",
                        title=debug_event,
                        message="",
                    )

How the fix is done

By changing the timestamp=datetime.datetime.now() to timestamp=datetime.datetime.now(datetime.timezone.utc) in all occurrence of ConsoleMessage constructor, i.e. in replace_print.py, data_processor.py and main_loop.py. This problem got fixed.

A unit test is added

A unit test to test the serialization/deserialization of the console message is added.

@bobbai00 bobbai00 force-pushed the jiadong-fix-py-console-message-timestamp branch from 8ffa1f9 to 79ed97e Compare September 3, 2024 14:55
Copy link
Collaborator

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Yicong-Huang
Copy link
Collaborator

@bobbai00 please make sure you update the PR description accordingly.

@bobbai00 bobbai00 merged commit 269fc99 into master Sep 5, 2024
8 checks passed
@bobbai00 bobbai00 deleted the jiadong-fix-py-console-message-timestamp branch September 5, 2024 00:35
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
This PR fixes the error of python udf stuck when betterproto is at
version `2.0.0b7`

This fix is compatible with betterproto `2.0.0b3` to `2.0.0b7`.

## The cause of the bug

When betterproto is at version `2.0.0b7`, timestamp requires the
timezone information. Otherwise, there will be exceptions if `print`
statements are in the python udf's code.

Before the fix, here is the code snippet of creating `ConsoleMessage` in
`pytexera`:
```python
ConsoleMessage(
                        worker_id=self.context.worker_id,
                        timestamp=datetime.datetime.now(),
                        msg_type=ConsoleMessageType.DEBUGGER,
                        source="(Pdb)",
                        title=debug_event,
                        message="",
                    )
```

## How the fix is done

By changing the `timestamp=datetime.datetime.now()` to
`timestamp=datetime.datetime.now(datetime.timezone.utc)` in all
occurrence of `ConsoleMessage` constructor, i.e. in `replace_print.py`,
`data_processor.py` and `main_loop.py`. This problem got fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants