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

add pre-commit config #63

Merged
merged 5 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
228 changes: 123 additions & 105 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,122 +1,140 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "petsird",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--platform=linux/amd64"
],
{
"name": "petsird",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--platform=linux/amd64"
],

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container
// create.
"settings": {
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,

"[cpp]": {
"editor.formatOnSave": true
},
"[cpp]": {
"editor.formatOnSave": true
},

"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},

"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},

"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},

"cmake.sourceDirectory": "${workspaceFolder}/cpp",
"cmake.buildDirectory": "${workspaceFolder}/cpp/build",
"cmake.configureOnOpen": false,
"cmake.sourceDirectory": "${workspaceFolder}/cpp",
"cmake.buildDirectory": "${workspaceFolder}/cpp/build",
"cmake.configureOnOpen": false,

"python.defaultInterpreterPath": "/opt/conda/envs/petsird/bin/python",
"python.analysis.typeCheckingMode": "strict",
"python.analysis.diagnosticMode": "workspace",
"python.analysis.diagnosticSeverityOverrides": {
"reportUnknownArgumentType": "none",
"reportUnknownLambdaType": "none",
"reportUnknownMemberType": "none",
"reportUnknownParameterType": "none",
"reportUnknownVariableType": "none",
"reportUnnecessaryIsInstance": "none",
"reportUnusedImport": "none"
},
"python.terminal.activateEnvironment": false, // Disable the extension calling activate when the integrated terminal launches. We take care of this in ~/.bashrc.
"python.defaultInterpreterPath":
"/opt/conda/envs/petsird/bin/python",
"python.analysis.typeCheckingMode": "strict",
"python.analysis.diagnosticMode": "workspace",
"python.analysis.diagnosticSeverityOverrides": {
"reportUnknownArgumentType": "none",
"reportUnknownLambdaType": "none",
"reportUnknownMemberType": "none",
"reportUnknownParameterType": "none",
"reportUnknownVariableType": "none",
"reportUnnecessaryIsInstance": "none",
"reportUnusedImport": "none"
},
"python.terminal.activateEnvironment": false,
// Disable the extension calling activate when the integrated
// terminal launches. We take care of this in ~/.bashrc.

"testMate.cpp.test.executables": "cpp/{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*",
"testMate.cpp.test.executables":
"cpp/{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*",

// enable pretty printing when debugging C++ tests
"testMate.cpp.debug.configTemplate": {
"type": "cppvsdbg",
"linux": { "type": "cppdbg", "MIMode": "gdb" },
"darwin": { "type": "cppdbg", "MIMode": "lldb" },
"win32": { "type": "cppvsdbg" },
"program": "${exec}",
"args": "${argsArray}",
"cwd": "${cwd}",
"env": "${envObj}",
"environment": "${envObjArray}",
"sourceFileMap": "${sourceFileMapObj}",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
// enable pretty printing when debugging C++ tests
"testMate.cpp.debug.configTemplate": {
"type": "cppvsdbg",
"linux": {
"type": "cppdbg",
"MIMode": "gdb"
},
"darwin": {
"type": "cppdbg",
"MIMode": "lldb"
},
"win32": {
"type": "cppvsdbg"
},
"program": "${exec}",
"args": "${argsArray}",
"cwd": "${cwd}",
"env": "${envObj}",
"environment": "${envObjArray}",
"sourceFileMap": "${sourceFileMapObj}",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],

"gitlens.showWelcomeOnInstall": false,
"gitlens.showWhatsNewAfterUpgrades": false
},
"gitlens.showWelcomeOnInstall": false,
"gitlens.showWhatsNewAfterUpgrades": false
},

"gcovViewer.gcovBinary": "/opt/conda/envs/petsird/bin/x86_64-conda-linux-gnu-gcov",
"gcovViewer.buildDirectories": ["${workspaceFolder}/cpp/build"],
"gcovViewer.gcovBinary":
"/opt/conda/envs/petsird/bin/x86_64-conda-linux-gnu-gcov",
"gcovViewer.buildDirectories": [
"${workspaceFolder}/cpp/build"
],

"search.useIgnoreFiles": false,
"search.exclude": {
"**/cpp/build": true
}
},

"search.useIgnoreFiles": false,
"search.exclude": {
"**/cpp/build": true
// Add the IDs of extensions you want installed when the container is
// created.
"extensions": [
"cschlosser.doxdocgen",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"JacquesLucke.gcov-viewer",
"matepek.vscode-catch2-test-adapter",
"mhutchie.git-graph",
"ms-python.black-formatter",
"ms-python.python",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"timonwong.shellcheck",
"twxs.cmake"
]
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"cschlosser.doxdocgen",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"JacquesLucke.gcov-viewer",
"matepek.vscode-catch2-test-adapter",
"mhutchie.git-graph",
"ms-python.black-formatter",
"ms-python.python",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"timonwong.shellcheck",
"twxs.cmake"
]
}
},

"overrideCommand": false,
"mounts": [
// Bind mount docker socket under an alias to support docker-from-docker
"source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind"
],
"overrideCommand": false,
"mounts": [
// Bind mount docker socket under an alias to support
// docker-from-docker
"source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind"
],

"remoteUser": "vscode"
}
"remoteUser": "vscode"
}
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Shell scripts should have LF
*.bashrc text eol=lf
*.sh text eol=lf
*.csh text eol=lf
*.csh text eol=lf
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

Please read and adhere to the [contribution guidelines](https://github.com/ETSInitiative/PRDdefinition/blob/master/CONTRIBUTING.md).

Please tick the following:
Please tick the following:

- [ ] The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in the ETSI software (the Work) under the terms and conditions of the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) License.
57 changes: 57 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
ci:
skip: [todo]

default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-toml
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: local
hooks:
- id: todo
name: Check TODO
language: pygrep
args: [-i]
entry: TODO
types: [text]
exclude: ^.pre-commit-config.yaml$
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
args: [-j8]
additional_dependencies:
- flake8-broken-line
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-isort
- flake8-pyproject
- flake8-string-format
- repo: https://github.com/google/yapf
rev: v0.40.2
hooks:
- id: yapf
args: [-i]
additional_dependencies: [toml]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Please by mindful about the resources used by our Continuous Integration (CI) wo
- `[actions skip]` does not run GitHub Actions, see [here](https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/).
8. After acceptance of your PR, go home with a nice warm feeling.

Suggested reading:
Suggested reading:
https://help.github.com/articles/fork-a-repo/, https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project or https://guides.github.com/activities/forking/.

### A note on copyright dates and notices (and licenses)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.

You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ This codespace/container will contain all necessary tools, including `yardl` its

4. Have a look at (and try!) the examples in the [`cpp`](cpp/README.md) and/or
[`python`](python/README.md) directories.


9 changes: 5 additions & 4 deletions cpp/petsird_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ main(int argc, char* argv[])

std::cout << "Last time block at " << last_time << " ms\n";
std::cout << "Number of prompt events: " << num_prompts << std::endl;
if (num_prompts > 0) {
std::cout << "Average energy_1: " << energy_1 / num_prompts << std::endl;
std::cout << "Average energy_2: " << energy_2 / num_prompts << std::endl;
}
if (num_prompts > 0)
{
std::cout << "Average energy_1: " << energy_1 / num_prompts << std::endl;
std::cout << "Average energy_2: " << energy_2 / num_prompts << std::endl;
}

return 0;
}
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
- ninja>=1.11.0
- nlohmann_json>=3.11.2
- numpy>=1.24.3
- pre-commit=4.0.1
- python>=3.11.3
- shellcheck>=0.8.0
- xtensor-fftw>=0.2.5
Expand Down
2 changes: 1 addition & 1 deletion model/DetectionEfficiencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ DetectionEfficiencies: !record
modulePairSGIDLUT: ModulePairSGIDLUT?
# Vector of all modulePairEfficiencies (one for each SGID)
# Constraint: size(modulePairEfficienciesVector) == max(modulePairSGIDLUT) + 1
modulePairEfficienciesVector: ModulePairEfficienciesVector?
modulePairEfficienciesVector: ModulePairEfficienciesVector?
2 changes: 1 addition & 1 deletion model/DetectorInformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DetectorModule: !record

# A list of identical modules at different locations
ReplicatedDetectorModule: ReplicatedObject< DetectorModule >

# Full definition of the geometry of the scanner, consisting of
# one of more types of modules replicated in space and (optional) other structures (e.g. side-shielding)
ScannerGeometry: !record
Expand Down
2 changes: 1 addition & 1 deletion model/ScannerInformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ScannerInformation: !record
# Geometric information for all detector elements
# All coordinates are in the PET gantry coordinate system.
scannerGeometry: ScannerGeometry

# List of materials present in the scanner geometry. The `material_id`s there will refer to the
# identifiers in this list below.
bulkMaterials: BulkMaterial*
Expand Down
Loading
Loading