agentos-project / agentos

The Python Component System (PCS) is an API and CLI for building, running, and sharing Python code. AgentOS is a set of libraries built on top of PCS that make it easy to build, run, and share agents that use Reinforcement Learning.
https://agentos.org
Apache License 2.0
13 stars 4 forks source link

`pathlib.Path.exists()` fails on windows with a github URL #415

Closed andyk closed 2 years ago

andyk commented 2 years ago

Inside _get_all_remotes() inside git_manager, we are currently using Path.exists() to test whether a string is a local path or not. When it isn't a local path, it is a github url, and this raises an error in Windows (but not linux).

https://github.com/agentos-project/agentos/blob/be38e022b4d92e76d307ea08050ef305263e04f5/pcs/git_manager.py#L126-L130

This fails in windows:

>>> import pathlib
>>> p = pathlib.Path('https:\\github.com\\DLR-RM\\stable-baselines3.git')
>>> p
WindowsPath('https:/github.com/DLR-RM/stable-baselines3.git')
>>> p.exists()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python39\lib\pathlib.py", line 1407, in exists
    self.stat()
  File "C:\Python39\lib\pathlib.py", line 1221, in stat
    return self._accessor.stat(self)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'https:\\github.com\\DLR-RM\\stable-baselines3.git'

...but not in Linux:

>>> import pathlib
>>> pathlib.Path('https:\\github.com\\DLR-RM\\stable-baselines3.git')
PosixPath('https:\\github.com\\DLR-RM\\stable-baselines3.git')
>>> p = pathlib.Path('https:\\github.com\\DLR-RM\\stable-baselines3.git')
>>> p
PosixPath('https:\\github.com\\DLR-RM\\stable-baselines3.git')
>>> p.exists()
False