Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

feat: Add jurigged hot reloading to debug extension #652

Merged
merged 15 commits into from
Oct 28, 2022
Merged

feat: Add jurigged hot reloading to debug extension #652

merged 15 commits into from
Oct 28, 2022

Conversation

zevaryx
Copy link
Contributor

@zevaryx zevaryx commented Sep 22, 2022

What type of pull request is this?

  • Non-breaking code change
  • Breaking code change
  • Documentation change/addition
  • Tests change

Description

jurigged is a library that can be used to patch Python code in memory, allowing for users to edit their bots while it is running and have the changes sync in real time with no downtime. This PR adds to the DebugExtension to allow jurigged to run and modify the bot as it is running, including re-syncing any commands that need to be resynced.

Changes

  • Add jurigged to DebugExtension

Checklist

  • I've formatted my code with Black
  • I've ensured my code works on Python 3.10.x
  • I've tested my code

@zevaryx
Copy link
Contributor Author

zevaryx commented Sep 22, 2022

testbot.zip

Here is the code I used to test this. In testbot/exts/test.py, you can add/remove commands, arguments, etc. You can also add other files with extensions in them to have them automatically load and sync

pyproject.toml Outdated Show resolved Hide resolved
@LordOfPolls
Copy link
Member

Purely because of how much of a selling point this is, and how complex it is under the hood, can i suggest you make a guide for its usage?

@zevaryx
Copy link
Contributor Author

zevaryx commented Sep 26, 2022

Purely because of how much of a selling point this is, and how complex it is under the hood, can i suggest you make a guide for its usage?

I'll get a PR open (or add a commit) to update the docs for the Debug cog to explain exactly what it is

@silasary
Copy link
Collaborator

Is there any way to disable it?

Depending on what I'm working on, I can foresee times when I would want the rest of DebugExtension, but juryrigged would cause invalid runtime states

@zevaryx
Copy link
Contributor Author

zevaryx commented Sep 27, 2022

Is there any way to disable it?

Depending on what I'm working on, I can foresee times when I would want the rest of DebugExtension, but juryrigged would cause invalid runtime states

Not by default. I could add a flag to disable it. I didn't add that since the rest of the debug extensions didn't have that, either

@silasary
Copy link
Collaborator

The rest of the debug extensions don't have any potential downsides of having them enabled ;)

@LordOfPolls
Copy link
Member

Any movement re the above comments @zevaryx?

@zevaryx
Copy link
Contributor Author

zevaryx commented Oct 8, 2022

I had asked about where to put the documentation in the Discord and never got a response. I'm probably going to create a subsection of the docs explaining all of the debug extensiona

@silasary
Copy link
Collaborator

The last discussion we had on discord was about moving it out of DebugExension, and making it a separate extension entirely

@zevaryx
Copy link
Contributor Author

zevaryx commented Oct 11, 2022

Yes! I have those changes made locally, but was waiting for the conversations on documentation. Been busy at work these last few weeks, but I'll get the changes finished and pushed this week

naff/ext/debug_extension/utils.py Outdated Show resolved Hide resolved
@zevaryx zevaryx requested a review from silasary October 18, 2022 00:49
@@ -5,6 +5,9 @@ These files contain useful features that help you develop a bot
- [Debug Extension](debug_ext)
- An extension preloaded with a load of debugging utilities to help you find and fix bugs

- [Jurigged](jurigged)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This name means nothing to people who don't already know the library. I'd rather call it "Live Editing" or "Hot Reloading" or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think "Live Patching" is a better name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, for the API reference, keeping the jurigged name should be fine; I'll update the other parts of the docs to reference it as Live Patching

@silasary silasary merged commit 9a9512c into 2.x Oct 28, 2022
@silasary silasary deleted the jurigged branch October 28, 2022 06:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants