-
Notifications
You must be signed in to change notification settings - Fork 31
Dashboard: update python parser #1140
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
base: development
Are you sure you want to change the base?
Changes from all commits
3fad621
aad51c8
f9af77f
ea1e80d
37052e6
cffe7ed
5fbdf67
e7e10a1
af1b7c5
42de35a
b3bc78e
b527496
cce57cb
0ae6eee
ff0916f
8789634
3b08807
d0bf944
fd37c15
87e3b72
f449595
61a2eb5
af2f50a
7068e92
01a3039
13271e7
ebdf01b
240ca26
733b0f7
41d9d85
eeaa9d1
58e0204
10373fc
105e646
49a95f4
2cd0f48
adb9618
3ea0c92
f226783
583c6d3
6833a6c
3c04630
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| License: BSD-3-Clause-LBNL | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
| from typing import Union | ||
|
|
||
| from .. import state | ||
|
|
@@ -139,3 +140,18 @@ | |
| current_input = getattr(state, state_name) | ||
| numeric_input = GeneralFunctions.convert_to_numeric(current_input) | ||
| setattr(state, state_name, numeric_input) | ||
|
|
||
| def get_impactx_root_dir() -> Path | None: | ||
| """ | ||
| Locates the ImpactX source directory. | ||
| Looks for the outermost parent directory named 'impactx' that contains a '.git' folder. | ||
| """ | ||
|
|
||
| current_directory = Path(__file__).resolve() | ||
| root_dir = None | ||
|
|
||
| for parent_dir in current_directory.parents: | ||
|
Comment on lines
+151
to
+154
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ax3l Thank you for the ping. Yes, there is a duplicate function in both this PR (#1140) and #876. At first, this was done intentionally when added in because (trying to recall correctly) it was difficult to have the pytests (from the directory Any suggestions for where the function |
||
| if parent_dir.name == "impactx" and (parent_dir / ".git").is_dir(): | ||
| root_dir = parent_dir # keep going until we reach the highest match | ||
|
Comment on lines
+155
to
+156
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @proy30 it looks to me like you are quite often assuming that ImpactX is used from its source tree. This is, outside of development, not the case. We install ImpactX like this: cmake -S . -B build -DImpactX_PYTHON=ON
cmake --build build -j 4 --target pip_installwhich copies things outside of the source tree. Thus, looking for a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ax3l Thank you for pointing this out. Will add a commit to work well in both development and non-development
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good! :) |
||
| return root_dir | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,15 +16,15 @@ | |
|
|
||
| DASHBOARD_EXAMPLES = { | ||
| "fodo/run_fodo.py", | ||
| # "chicane/run_chicane_csr.py", | ||
| # "fodo_space_charge/run_fodo_envelope_sc.py", | ||
| # "apochromatic/run_apochromatic.py", | ||
| # "kurth/run_kurth_10nC_periodic.py", | ||
| # "expanding_beam/run_expanding_fft.py", | ||
| # "expanding_beam/run_expanding_envelope.py", | ||
| # "iota_lattice/run_iotalattice.py", | ||
| # "cyclotron/run_cyclotron.py", | ||
| # "dogleg/run_dogleg.py", | ||
| "chicane/run_chicane_csr.py", | ||
| "fodo_space_charge/run_fodo_envelope_sc.py", | ||
| "apochromatic/run_apochromatic.py", | ||
| # "kurth/run_kurth_10nC_periodic.py", - running into recursion issues | ||
| "expanding_beam/run_expanding_fft.py", | ||
| "expanding_beam/run_expanding_envelope.py", | ||
| "iota_lattice/run_iotalattice.py", | ||
| "cyclotron/run_cyclotron.py", | ||
| "dogleg/run_dogleg.py", | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -64,7 +64,7 @@ def _get_example_content(file_name: str) -> dict: | |
| Retrieve the selected ImpactX example file and populate the UI with its values. | ||
| """ | ||
|
|
||
| impactx_directory = DashboardExamplesLoader.get_impactx_path() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep using the old path and logic from |
||
| impactx_directory = GeneralFunctions.get_impactx_root_dir() | ||
| impactx_example_file_path = impactx_directory / "examples" / file_name | ||
|
|
||
| file_content_as_str = impactx_example_file_path.read_text() | ||
|
|
@@ -81,8 +81,9 @@ def load_impactx_examples() -> None: | |
|
|
||
| state.impactx_example_list.clear() | ||
|
|
||
| impactx_directory = DashboardExamplesLoader.get_impactx_path() | ||
| impactx_directory = GeneralFunctions.get_impactx_root_dir() | ||
| impactx_examples_directory = impactx_directory / "examples" | ||
| print(" the examples directory is ", impactx_examples_directory) | ||
|
|
||
| for path in impactx_examples_directory.glob("**/run*"): | ||
| relative_path = path.relative_to(impactx_examples_directory) | ||
|
|
||

Check notice
Code scanning / CodeQL
First parameter of a method is not named 'self' Note