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

Adds example projects #59

Merged
merged 3 commits into from
Nov 19, 2024
Merged

Conversation

alexhroom
Copy link
Collaborator

This PR adds example projects generated from the python-RAT examples, and also includes the generation script.

@alexhroom alexhroom force-pushed the add-examples branch 3 times, most recently from 272d355 to e132515 Compare November 12, 2024 09:49
Copy link
Contributor

@StephenNneji StephenNneji left a comment

Choose a reason for hiding this comment

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

Thanks for this, please remember to address the empty controls.json issue. Also can you make it so new lines are stripped when loading the json (Lines 100 and 109), some editors add a new line by default and the loading kept failing even though the content was mostly the same except for the new line.

controls = RAT.Controls.model_validate_json(controls_file.read_text())
except ValueError as err:
raise ValueError(
"The controls.json file for this project is not valid.\n"
"It may contain invalid parameter values or be invalid JSON."
) from err
project_file = Path(load_path, "project.json")
try:
project = RAT.utils.convert.project_from_json(project_file.read_text())

@alexhroom
Copy link
Collaborator Author

@StephenNneji I've added an .rstrip() to the project load but couldn't reproduce the problem you were having: do you just mean an extra newline at the end of the JSON file?

also turns out that the controls saving did do what you wanted (saves all defaults). I just misremembered how it worked. i've updated all the controls to match what they are in the python-RAT examples (all default except for absorption which parallelises over contrasts and uses 150 resample points)

@alexhroom alexhroom merged commit 770e48b into RascalSoftware:main Nov 19, 2024
4 checks passed
@alexhroom alexhroom deleted the add-examples branch November 19, 2024 10:17
@StephenNneji
Copy link
Contributor

@StephenNneji I've added an .rstrip() to the project load but couldn't reproduce the problem you were having: do you just mean an extra newline at the end of the JSON file?

I can't replicate anymore on the old commit, not sure what changed. I might have somehow introduced an error when testing but at the time I was getting this error

2024-11-18 13:46:07,325 - MainThread - rascal_log - ERROR - Failed to load project at path /home/stephen/Downloads/RasCAL-2-add-examples/examples/domains_standard_layers:
The controls.json file for this project is not valid.
It may contain invalid parameter values or be invalid JSON.

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.

2 participants