-
Notifications
You must be signed in to change notification settings - Fork 18
✨ Project Class #869
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
Merged
Merged
✨ Project Class #869
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
58573cc
Created basic project class.
joernweissenborn f0d97d9
Added `Project.markdown`
joernweissenborn c265ceb
🩹 Fixed issue with circular imports
s-weigand 4f8c291
🩹 Fixed changed generator API
s-weigand 14f3e39
🩹 Fixed changed import paths of simulated test data
s-weigand 29e8e70
🩹 Fixed broken tests
s-weigand 6340e6f
🩹 Fixed wrong stacklevel of folder and legacy plugin warnings
s-weigand cc2d101
♻️ Refactored by Sourcery
6db5ab3
🩹 Use save result "yml" instead of "folder"
s-weigand 7ea5462
🧹 Removed unused variables
s-weigand d64e834
Switched to builtin yaml in project
joernweissenborn 3648358
Refactored parameter generation
joernweissenborn 497c063
Changed default saving of result to yml
joernweissenborn 3d1c38b
Changed project open and create logic.
joernweissenborn d5edfc1
Added all known formats to project data.
joernweissenborn 0a8bcad
Various tweaks.
joernweissenborn c65b2d3
Moved get_script_folder to utils.io.
joernweissenborn e24df5a
Tweaks.
joernweissenborn 048f5e7
♻️ Refactored by Sourcery
47adfeb
🧪🩹 Changed expected yml string due to bug in ruamel yaml
s-weigand babe083
Added tests for load result.
joernweissenborn a90bd58
Added unit test for Model.get_parameter_labels.
joernweissenborn 4bc226e
Removed unescessray folder.exist checks.
joernweissenborn 09bf751
Guard Project.create from accidential overwrite.
joernweissenborn f95bef1
Renamed argument 'name' of Project.gernerate_model to 'generator_name'.
joernweissenborn a5ee140
Added methods to get a projects model and parameter directory.
joernweissenborn 9cfd874
Use dedent in project markdown.
joernweissenborn ec963c4
Removed unnessecary Path instance checks.
joernweissenborn 173f3b1
Use save dataset in project import dataset.
joernweissenborn 34e176f
Make project_folder field in Project class optionally if instanciated…
joernweissenborn 7a43f83
Removed unnessecary Path instance checks.
joernweissenborn b5634f0
Renamed argument 'generate' of ProjectModelRegistry.generate_model to…
joernweissenborn 0e3a889
Improved result name creation.
joernweissenborn 5a040c4
Fix Project.open.
joernweissenborn 11c97da
Tweaked project test.
joernweissenborn 43e3a10
Added guard to project model and parameter generation.
joernweissenborn 1e4c2c5
Return the project instance in Project.create.
joernweissenborn 7f994aa
Included sourcery and sonarcloud suggestions.
joernweissenborn 4df7ff5
Renamed overwrite to allow overwrite in project.
joernweissenborn 45e97c1
Use numbered results also when name is specified.
joernweissenborn 4ab3d44
Replaced 'with_suffix().name' with 'stem'
joernweissenborn c2c4e78
Fixed project template string quotation
joernweissenborn bfe71bb
Added 'ignore_existing' to project data import.
joernweissenborn 995fa42
👌 Changed implicit reraise to from reraise
s-weigand d821ddd
👌 Added allow_overwrite and ignore_existing options to project genera…
s-weigand 2b23d57
👌 Added zero padding to result run number to improve string sorting
s-weigand 6f5be80
👌 Added latest result fallback if run specifier is missing in result …
s-weigand c5375ff
🧪 Raised test coverage
s-weigand 9eed892
👌 Added tests for markdown and magic jupyter method
s-weigand fa29e79
🩹 Fixed wrong renaming
s-weigand 2eef676
🩹 Fixed naming inconsistency
s-weigand c6b91c1
🩹 Fix wrong item order on linux
s-weigand ea9a5d5
👌 Changed result run zero padding to 04
s-weigand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """Utility functionality module for ``glotaran.builtin.io.yml.yml``""" | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from ruamel.yaml import YAML | ||
| from ruamel.yaml.compat import StringIO | ||
|
|
||
| if TYPE_CHECKING: | ||
| from typing import Any | ||
| from typing import Mapping | ||
| from typing import Sequence | ||
|
|
||
| from ruamel.yaml.nodes import ScalarNode | ||
| from ruamel.yaml.representer import BaseRepresenter | ||
|
|
||
|
|
||
| def write_dict( | ||
| data: Mapping[str, Any] | Sequence[Any], file_name: str | Path | None = None, offset: int = 0 | ||
| ) -> str | None: | ||
| yaml = YAML() | ||
| yaml.representer.add_representer(type(None), _yaml_none_representer) | ||
| yaml.indent(mapping=2, sequence=2, offset=offset) | ||
|
|
||
| if file_name is not None: | ||
| with open(file_name, "w") as f: | ||
| yaml.dump(data, f) | ||
| else: | ||
| stream = StringIO() | ||
| yaml.dump(data, stream) | ||
| return stream.getvalue() | ||
|
|
||
|
|
||
| def load_dict(source: str | Path, is_file: bool) -> dict[str, Any]: | ||
| yaml = YAML() | ||
| yaml.representer.add_representer(type(None), _yaml_none_representer) | ||
| if is_file: | ||
| with open(source) as f: | ||
| spec = yaml.load(f) | ||
| else: | ||
| spec = yaml.load(source) | ||
| return spec | ||
|
|
||
|
|
||
| def _yaml_none_representer(representer: BaseRepresenter, data: Mapping[str, Any]) -> ScalarNode: | ||
| """Yaml repr for ``None`` python values. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| representer : BaseRepresenter | ||
| Representer of the :class:`YAML` instance. | ||
| data : Mapping[str, Any] | ||
| Data to write to yaml. | ||
|
|
||
| Returns | ||
| ------- | ||
| ScalarNode | ||
| Node representing the value. | ||
|
|
||
| References | ||
| ---------- | ||
| https://stackoverflow.com/a/44314840 | ||
| """ | ||
| return representer.represent_scalar("tag:yaml.org,2002:null", "null") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.