Skip to content

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

@hcadavid

Description

@hcadavid

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions