The code generated by the template creates a MockAlgorithClient instance passing a 'database' key value of type PosixPath (the type returned by Path(__file__).parent:
|
current_path = Path(__file__).parent |
|
|
|
## Mock client |
|
client = MockAlgorithmClient( |
|
datasets=[ |
|
# Data for first organization |
|
[{ |
|
"database": current_path / "test_data.csv", |
|
"db_type": "csv", |
|
"input_data": {} |
|
}], |
However, the MockAlgorithmClient constructor uses this key value as the database_uri argument of wrapper's load_data, which, by definition, should be a string:
https://github.com/vantage6/vantage6/blob/2a16890bde9abaf61cf134b00d8553ff5b5ce276/vantage6-algorithm-tools/vantage6/algorithm/tools/wrappers.py#L58-L60
This inconsistency makes the mock-client code generated by v6 algorithm create crash when using a SQL data source, as the load_data implementation for SQL uses string functions (endswith, split, etc).
As a workaround for the algorithm I'm working on, I simply use str() on these keys:
"database": str(current_path / "db-10k.db.sqlite"),
The code generated by the template creates a MockAlgorithClient instance passing a 'database' key value of type PosixPath (the type returned by
Path(__file__).parent:v6-algorithm-template/test/test.py.jinja
Lines 18 to 28 in f9073e8
However, the MockAlgorithmClient constructor uses this key value as the
database_uriargument of wrapper'sload_data, which, by definition, should be a string:https://github.com/vantage6/vantage6/blob/2a16890bde9abaf61cf134b00d8553ff5b5ce276/vantage6-algorithm-tools/vantage6/algorithm/tools/wrappers.py#L58-L60
This inconsistency makes the mock-client code generated by
v6 algorithm createcrash when using a SQL data source, as theload_dataimplementation for SQL uses string functions (endswith, split, etc).As a workaround for the algorithm I'm working on, I simply use
str()on these keys:"database": str(current_path / "db-10k.db.sqlite"),