question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Adding locals as an available attribute in callbacks

See original GitHub issue

🚀 Feature

In methods inside BaseCallback like _on_step, passing locals_ can be extremely helpful when there’s a need to override some default behaviour.

Motivation

In this particular case, I’m looking to override some default action structure to fit to a custom(unfortunately can’t disclose any code) environment - for which a clean approach is to use callbacks, but I need access to the actions of the policy before being passed onto env.step()

Pitch

Access to locals passed into the callback on policy and environment related methods in the BaseCallback

### Checklist

  • I have checked that there is no similar issue in the repo (required)

Thanks a lot, in advance! Apologies if this has been discussed elsewhere, couldn’t find it myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ReHosscommented, Aug 5, 2022

A quick way to see the relevant variable in your algorithm of choice is simply print all the keys in the self.locals.

class CustomCallback(BaseCallback):
    def _on_step(self):
        print(self.locals.keys()) # key's should contain 'actions' or the attribute you want to monitor
        # log the attribute self.locals['attribute_name']

In this case it might be easier to check and monitor each key with _actions in it to be algo agnostic, but there can be multiple of them. @ReHoss

Thanks I was going to inspect self.locals in my given context.

0reactions
ReHosscommented, Aug 5, 2022

Yep I got it thank you:)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Callbacks | Dash for Python Documentation | Plotly
This section describes the circumstances under which the dash-renderer front-end client can make a request to the Dash back-end server (or the clientside ......
Read more >
Logic App: Add callback url as attribute of http request trigger
This Resource wants me to set the "callback_url". I found this article, where it says, that the logic app itself (azurerm_logic_app_workflow) ...
Read more >
Requests and Responses — Scrapy 2.7.1 documentation
The callback of a request is a function that will be called when the response of that request is downloaded. The callback function...
Read more >
Callbacks - MoodleDocs
However if it is possible to achieve the desired outcome with event observer, Moodle will not accept requests for adding a "hook point"....
Read more >
Set up queued callback - Amazon Connect
Create a flow for queued callbacks · Request a callback number from a customer. · Store the callback number in an attribute. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found