Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent types in MockAlgorithm's template 'database' key #4

Open
hcadavid opened this issue Jul 15, 2024 · 0 comments
Open

Inconsistent types in MockAlgorithm's template 'database' key #4

hcadavid opened this issue Jul 15, 2024 · 0 comments

Comments

@hcadavid
Copy link

hcadavid commented Jul 15, 2024

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"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant