trading_agent.extensions.source_fetcher
¶
Turns a folder, a zip file or a git URL into a local folder, for imports and installs.
Both trading-agent skills import and trading-agent packages install accept the same three kinds of source, so this one class fetches them.
Typical usage example:
with tempfile.TemporaryDirectory() as scratch: folder = SourceFetcher().local_folder('https://github.com/someone/skills.git', Path(scratch))
SourceError
¶
Bases: RuntimeError
The source does not exist, or cannot be cloned or unpacked.
SourceFetcher
¶
Fetches import sources.
local_folder
¶
Turns a source into a local folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
A folder, a .zip file, or a git URL. |
required |
scratch
|
Path
|
A temporary folder for unpacking or cloning, which the caller deletes. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The folder, which for a local folder is the folder itself. |
Raises:
| Type | Description |
|---|---|
SourceError
|
The source cannot be used. |
Source code in src/trading_agent/extensions/source_fetcher.py
is_git_url
¶
Says whether a source is a git URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
The source. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for http, https, ssh and git@ addresses. |