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

Input format for components #31

Closed
wants to merge 24 commits into from
Closed

Input format for components #31

wants to merge 24 commits into from

Conversation

sylvlecl
Copy link
Member

Proposition of input format for components and parameter values.

Copy link
Member Author

@sylvlecl sylvlecl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! A few minor comments.

src/andromede/study/network_components.py Outdated Show resolved Hide resolved
src/andromede/study/resolve_components.py Outdated Show resolved Hide resolved
src/andromede/study/resolve_components.py Outdated Show resolved Hide resolved
@sylvlecl sylvlecl marked this pull request as ready for review April 23, 2024 09:24
@vargastat vargastat force-pushed the feature/components_yaml branch from 6a3c638 to 7bf7637 Compare April 23, 2024 16:21
@vargastat vargastat force-pushed the feature/components_yaml branch from 7bf7637 to aff0de8 Compare April 23, 2024 16:26
Copy link
Member

@flomnes flomnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little bit of bike shedding

Comment on lines 113 to 116
try:
return pd.read_csv(ts_path, header=None, sep="\s+")
except FileNotFoundError:
raise FileNotFoundError(f"File '{timeseries_name}' does not exist")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's a good thing to add this exception try/catch. Your error message brings less info than the original one. If you want to keep this mechanism, please print at least the full file path with extension aka ts_path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you are right, many things can go wrong I but Exception instead and whole file_path and name in the message

return InputComponents.model_validate(tree["study"])


# Design note: actual parsing and validation is delegated to pydantic models
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note : C++ has no pydantic. What does this do for us ?

Copy link
Member Author

@sylvlecl sylvlecl May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, pydantic is used here to convert from a dictionary/list representation to object oriented representation, including validation of inputs.

Depending on available libs on c++ side, we will most likely need to implement more things by ourselves (c++ does not have reflection so it cannot really automate this kind of object construction, unlike python/java).

Comment on lines +110 to +111
if path_to_file is not None and timeseries_name is not None:
timeseries_with_extension = timeseries_name + ".txt"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit strange. Why add the prefix here ?

I understand that we don't want ".txt" in the yaml files, but this adds implicit knowledge (the file XXX.txt must be referenced as XXX in the yaml).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to hand different extensions and that the final user should only put timeseries file name in the .yaml file

Comment on lines +19 to +36
@pytest.fixture
def input_component(
data_dir: Path,
) -> InputComponents:
compo_file = data_dir / "components.yml"

with compo_file.open() as c:
return parse_yaml_components(c)


@pytest.fixture
def input_library(
data_dir: Path,
) -> InputLibrary:
library = data_dir / "lib.yml"

with library.open() as lib:
return parse_yaml_library(lib)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be separate directories, with possibly multiple files.

study/
├── components
├── libraries
└── timeseries

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is only for tests purposes because in Python it is difficult to resolve absolut paths in test mode but in real scenario the file directories you describe are OK

@vargastat vargastat closed this May 13, 2024
@vargastat
Copy link
Contributor

New pull request will be created

@vargastat vargastat mentioned this pull request May 13, 2024
@tbittar tbittar deleted the feature/components_yaml branch May 14, 2024 08:17
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

Successfully merging this pull request may close these issues.

3 participants