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.

Bug when creating AgentManagers

See original GitHub issue

Hello, I was recently working with the agent checks on rlberry/utils/check_agent.py and I was encountering the following error:

fatal: not a git repository (or any of the parent directories): .git Traceback (most recent call last): File “./examples/demo_examples/demo_sb_agent.py”, line 30, in <module> stats = AgentManager( File “/Users/mmcenta/miniconda3/envs/rlb/lib/python3.8/site-packages/rlberry/manager/agent_manager.py”, line 386, in init self.rlberry_version = get_rlberry_version() File “/Users/mmcenta/miniconda3/envs/rlb/lib/python3.8/site-packages/rlberry/utils/hash_utils.py”, line 25, in get_rlberry_version subprocess.check_output( File “/Users/mmcenta/miniconda3/envs/rlb/lib/python3.8/subprocess.py”, line 415, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File “/Users/mmcenta/miniconda3/envs/rlb/lib/python3.8/subprocess.py”, line 516, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command ‘[‘git’, ‘rev-parse’, ‘HEAD’]’ returned non-zero exit status 128.

It is caused by the get_rlberry_version() function introduced recently (in PR #126), which requires the current directory (or its parent) to be a git repository. As it turns out, after installing the library with pip install ., this function is called from inside the library (somewhere in ~/miniconda3/envs/rlb/lib/python3.8/site-packages/rlberry/utils, in my case). The result is the error above because the other directory is not part of a git repository.

Reproducing

The code below reproduces the bug:

from rlberry.agents.torch import A2CAgent
from rlberry.envs import gym_make
from rlberry.manager import AgentManager

if __name__ == "__main__":
    env_ctor = gym_make
    env_kwargs = {'id': 'CartPole-v0'}
    stats = AgentManager(
        A2CAgent,
        (env_ctor, env_kwargs),
        agent_name="A2C",
        init_kwargs=dict(batch_size=16),
        fit_budget=100,
    )

Running this code produces the same error from above. Do NOT run the code from the rlberry main directory, because in that case it will import the local code which runs in a git directory. I run this code from a subdirectory rlberry/test_bug/bug.py, which forces Python to load the installed version of rlberry.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
TimotheeMathieucommented, Mar 3, 2022

This is now entirely solved.

The version is now in a static file rlberry/_version.py and this file define rlberry.__version__ that is automatically recorder in AgentManager and also it is recorded in the doc and setup.py. The _version.py file is automatically updated by a workflow that activate at each PR merge. This creates a commit that changes the version.

Typical version is __version__ = "v0.2.1.post82.dev0+feb610b "

which means v0.2.1 (from the tag) after which we did 82 commits on main branch, the last of which has hash feb610b. This indicate precisely which version of rlberry was used and because it is in the github workflow, there is no need to change the version locally, so no dependency on git or anything of the sort.

1reaction
TimotheeMathieucommented, Mar 1, 2022

The thing is that tests are run from rlberry main directory which is why it was not spotted. I actually don’t really understand why you had the error because on my PC, with pip install . -e it works, maybe a difference with windows or other ? Anyway I am working on a cleaner solution in the PR. I don’t think I could do a regression test for this, I would have to run the tests from outside rlberry folder, but pytest automatically runs tests from inside rlberry folder I think.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How agents and development team work on bug reports ...
When service project agents work on bug reports raised by customers, they may need to work with the development teams to let them...
Read more >
Troubleshoot agent connectivity issues - Operations Manager
This guide helps you troubleshoot issues that Operations Manager agents have problem connecting to the management server in System Center ...
Read more >
Troubleshooting Management Agent Startup Errors
Securing or unsecuring of the Management Agent can fail if the password to secure the agent against the OMS is incorrect or if...
Read more >
ITSM Agent Workspace | Problem - YouTube
How to access Problems in Agent Workspace, create a problem task, and attach a knowledge article using Agent Assist.
Read more >
ITSM Agent Workspace - Problem
When you have recurring incidents or a major incident, you can create a problem to identify the root cause of the incidents and...
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