Skip to content

Commit

Permalink
release draft fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lalmei committed Dec 2, 2024
1 parent 02b0f61 commit 7332a38
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 40 deletions.
File renamed without changes.
24 changes: 12 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 5 additions & 8 deletions agml/synthetic/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
53 changes: 33 additions & 20 deletions agml/synthetic/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import os
import re
import stat
import sys
import subprocess as sp
import sys

Expand Down Expand Up @@ -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}.")
Expand All @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7332a38

Please sign in to comment.