From 7332a3876df77a00cdd8287b52f3bd8786efd30a Mon Sep 17 00:00:00 2001 From: "Leandro G. Almeida" Date: Mon, 2 Dec 2024 13:57:58 -0800 Subject: [PATCH] release draft fix --- {config => .github}/release_draft.yml | 0 CONTRIBUTING.md | 24 ++++++------ agml/synthetic/compilation.py | 13 +++---- agml/synthetic/manual.py | 53 +++++++++++++++++---------- 4 files changed, 50 insertions(+), 40 deletions(-) rename {config => .github}/release_draft.yml (100%) diff --git a/config/release_draft.yml b/.github/release_draft.yml similarity index 100% rename from config/release_draft.yml rename to .github/release_draft.yml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3b2be648..6e32b34c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -189,34 +189,34 @@ We will then review the changes and review next steps for adding the dataset int ### Installing uv -<<<<<<< HEAD - -Install uv follow the guidelines in https://docs.astral.sh/uv/getting-started/installation/, it is recommended to use the standalone installation. -======= Dependencies and admin actions are done using `uv`. To Install uv follow the guidelines in https://docs.astral.sh/uv/getting-started/installation/, it is recommended to use the standalone installation. ->>>>>>> dev ### Building Project -The build the associated wheels simply run: +To sync the dependencies and create a local env that fits the requirements, simply run: -``` -make build + +```bash +make install ``` -To sync the dependencies simply run: +This will install both requirements and necessary development dependencies, such as `dev` and `docs` dependency groups. To build the wheels: -``` -uv sync + +```bash +make build ``` ### Running tests -``` +To run all the tests with associated coverage: + +```bash make test ``` + ### Running scripts For running scripts or one-offs using the project's installed enviroment diff --git a/agml/synthetic/compilation.py b/agml/synthetic/compilation.py index aa0f31b2..1254e286 100644 --- a/agml/synthetic/compilation.py +++ b/agml/synthetic/compilation.py @@ -20,20 +20,17 @@ import sys import tempfile from datetime import datetime as dt +from pathlib import Path -from agml.backend.config import _update_config, _get_config +from agml.backend.config import _get_config, _update_config from agml.synthetic.config import HELIOS_PATH, PROJECT_ROOT -from pathlib import Path PROJECT = "SyntheticImageAnnotation" # Helios build and compilation paths. -PROJECT_PATH = os.path.join( - PROJECT_ROOT, PROJECT) -HELIOS_BUILD = os.path.join( - PROJECT_PATH, 'build') -HELIOS_EXECUTABLE = os.path.join( - PROJECT_PATH, 'build', PROJECT) +PROJECT_PATH = os.path.join(PROJECT_ROOT, PROJECT) +HELIOS_BUILD = os.path.join(PROJECT_PATH, "build") +HELIOS_EXECUTABLE = os.path.join(PROJECT_PATH, "build", PROJECT) # Helios parameter paths. XML_PATH = os.path.join(PROJECT_PATH, "xml") diff --git a/agml/synthetic/manual.py b/agml/synthetic/manual.py index 0b30f48c..e902d48a 100644 --- a/agml/synthetic/manual.py +++ b/agml/synthetic/manual.py @@ -15,7 +15,6 @@ import os import re import stat -import sys import subprocess as sp import sys @@ -107,7 +106,9 @@ def generate_manual_data( ) # Check that the necessary files exist. - if not os.path.exists(os.path.join(project_path, 'main.cpp')) and not os.path.exists(os.path.join(project_path, 'generate.cpp')): + if not os.path.exists(os.path.join(project_path, "main.cpp")) and not os.path.exists( + os.path.join(project_path, "generate.cpp") + ): raise ValueError(f"Could not find `main.cpp` file at {project_path}.") if not os.path.exists(os.path.join(project_path, "CMakeLists.txt")): raise ValueError(f"Could not find `CMakeLists.txt` file at {project_path}.") @@ -119,10 +120,10 @@ def generate_manual_data( with open(os.path.join(SUPER_BASE_DIR, ".last_manual_compilation_cpp.cpp"), "r") as f: legacy_cpp = f.read() try: - with open(os.path.join(project_path, 'main.cpp'), 'r') as f: + with open(os.path.join(project_path, "main.cpp"), "r") as f: current_cpp = f.read() except FileNotFoundError: - with open(os.path.join(project_path, 'generate.cpp'), 'r') as f: + with open(os.path.join(project_path, "generate.cpp"), "r") as f: current_cpp = f.read() if legacy_cpp == current_cpp: cpp_same = True @@ -138,12 +139,17 @@ def generate_manual_data( # Compile Helios. if not cpp_same and not cmake_same: # Construct arguments for the compilation. - helios_build = os.path.join(project_path, 'build') - cmake_args = ['cmake', '..', '-G', 'Unix Makefiles', - f'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={helios_build}', - f'-DCMAKE_BUILD_TYPE={cmake_build_type}'] - make_args = ['cmake', '--build', '.'] - log_file = os.path.join(SUPER_BASE_DIR, '.last_helios_manual_compilation.log') + helios_build = os.path.join(project_path, "build") + cmake_args = [ + "cmake", + "..", + "-G", + "Unix Makefiles", + f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={helios_build}", + f"-DCMAKE_BUILD_TYPE={cmake_build_type}", + ] + make_args = ["cmake", "--build", "."] + log_file = os.path.join(SUPER_BASE_DIR, ".last_helios_manual_compilation.log") if os.path.exists(log_file): os.unlink(log_file) @@ -207,27 +213,34 @@ def generate_manual_data( sys.stderr.write("\nHelios compilation successful!") # Run the generation. - executable = os.path.join(project_path, 'build', project_name) - os.chmod(executable, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | - stat.S_IROTH | stat.S_IXOTH) # add necessary permissions to executable + executable = os.path.join(project_path, "build", project_name) + os.chmod( + executable, + stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH, + ) # add necessary permissions to executable env = os.environ.copy() - if os.path.exists('/usr/lib/wsl/lib'): # if using WSL, this is mandatory to use radiation plugin - env['LD_LIBRARY_PATH'] += ':/usr/lib/wsl/lib' - process = sp.Popen([executable], stdout = sp.PIPE, stderr = sp.STDOUT, - cwd = os.path.join(project_path, 'build'), env=env, - universal_newlines = True, ) + if os.path.exists("/usr/lib/wsl/lib"): # if using WSL, this is mandatory to use radiation plugin + env["LD_LIBRARY_PATH"] += ":/usr/lib/wsl/lib" + process = sp.Popen( + [executable], + stdout=sp.PIPE, + stderr=sp.STDOUT, + cwd=os.path.join(project_path, "build"), + env=env, + universal_newlines=True, + ) for line in iter(process.stdout.readline, ""): sys.stdout.write(line) process.stdout.close() process.wait() # Save the existing files for comparison in future runs. - with open(os.path.join(SUPER_BASE_DIR, '.last_manual_compilation_cpp.cpp'), 'w') as f: + with open(os.path.join(SUPER_BASE_DIR, ".last_manual_compilation_cpp.cpp"), "w") as f: if code is not None and not os.path.exists(code): f.write(code) else: f.write(current_cpp) - with open(os.path.join(SUPER_BASE_DIR, '.last_manual_compilation_cmake.txt'), 'w') as f: + with open(os.path.join(SUPER_BASE_DIR, ".last_manual_compilation_cmake.txt"), "w") as f: if cmake is not None and not os.path.exists(cmake): f.write(cmake) else: