Skip to content

Using relative config files in dicts and lists raises Unexpected import path format #557

@AlejandroBaron

Description

@AlejandroBaron

Using relative config files in dicts doesn't work. It might be that I'm not using the correct syntax tho

To reproduce

3 files in the same directory

  1. cli.py
from jsonargparse import CLI
from typing import Dict, List

class MyObject:

    def __init__(self, x: int) -> None:
        self.x = x


class MyCLI:

    def __init__(self, d: Dict[str, MyObject]) -> None:
        self.d = d


CLI(MyCLI)

(If you use a List instead of Dict for d param, same error happens)

  1. main.yaml
d:
  obj1: ./my_obj.yaml
  1. my_obj.yaml
class_path: cli.MyObj
init_args:
  x: 3

Command: python cli.py --config main.yaml. Raises

error: Parser key "d":
  Unexpected import path format: ./my_obj.yaml

As I said it might not be a bug. I'm using python 3.8, but in the project that triggered this error I'm using python 3.9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions