Skip to content

Docker adaptation for windows #317

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

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6eb1067
new modification
May 14, 2025
22e0d4c
flake 8
GBenedett May 15, 2025
3aa2f9c
flake
GBenedett May 15, 2025
725567d
removed unused import
GBenedett May 15, 2025
bdcf853
unused print removed
GBenedett May 15, 2025
af3af88
changed description
GBenedett May 15, 2025
83932e4
ceasiompy module not found error corrected
LeonDeligny May 15, 2025
0dfd69e
Merge branch 'docker_modification' of https://github.com/cfsengineeri…
LeonDeligny May 15, 2025
0de6a2f
update source in workflow
LeonDeligny May 15, 2025
ec7dc17
add src to python path
LeonDeligny May 15, 2025
4067927
add magic mock for test all module test function
LeonDeligny May 15, 2025
73ec34a
cleaning src/bin of CEASIOMpy
LeonDeligny May 16, 2025
6a4a4f8
renaming folder streamlit to CEASIOMpyStreamlit to avoid confusion wh…
LeonDeligny May 16, 2025
2c543bf
put ceasiompy in src
LeonDeligny May 16, 2025
e3298ba
change command for unittest
LeonDeligny May 16, 2025
95ebe2c
change ceaiompy.log path
LeonDeligny May 16, 2025
a345f5c
change workflow path
LeonDeligny May 16, 2025
cc08a7f
test
LeonDeligny May 16, 2025
158a795
test
LeonDeligny May 16, 2025
5c8be25
test
LeonDeligny May 16, 2025
0ef65d3
test
LeonDeligny May 16, 2025
3914fa4
normal log
LeonDeligny May 16, 2025
d923349
correct testmoduletorun
LeonDeligny May 16, 2025
d6d2570
correct testmoduletorun
LeonDeligny May 16, 2025
8dfc753
correct testmoduletorun
LeonDeligny May 16, 2025
5af0026
correct testmoduletorun
LeonDeligny May 16, 2025
c318bc6
correct testmoduletorun
LeonDeligny May 16, 2025
ef3ff27
correct testmoduletorun
LeonDeligny May 16, 2025
5912668
correct testmoduletorun
LeonDeligny May 16, 2025
5b2ae6b
correct testmoduletorun
LeonDeligny May 16, 2025
a20677b
correct testmoduletorun
LeonDeligny May 16, 2025
2f72224
correct testmoduletorun
LeonDeligny May 16, 2025
3ac79c1
correct testmoduletorun
LeonDeligny May 16, 2025
c90d039
correct testmoduletorun
LeonDeligny May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 5 additions & 2 deletions .github/workflows/integrationtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,15 @@ jobs:
- name: Install Pentagrow
shell: bash -l {0}
run: installation/Ubuntu/install_pentagrow.sh


- name: Add src to PYTHONPATH
run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)/src" >> $GITHUB_ENV

- name: Run integration tests
shell: bash -l {0}
run: |
source ~/.bashrc
pytest -v ./tests --cov=ceasiompy/ --cov-report xml:coverage.xml -m "not gui"
pytest -v ./tests --cov=ceasiompy --cov-report xml:coverage.xml -m "not gui"

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.0
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ jobs:
- name: Install libGLU
run: sudo apt-get install -y libglu1-mesa-dev

- name: Add src to PYTHONPATH
run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)/src" >> $GITHUB_ENV

- name: Run unit tests
shell: bash -l {0}
run: pytest -v ./ceasiompy --cov=ceasiompy/ --cov-report xml:coverage.xml
run:
pytest -v src/ceasiompy --cov=ceasiompy --cov-report xml:coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.0
Expand Down
4 changes: 1 addition & 3 deletions CEASIOMpy_docker_Installation
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ COPY src /CEASIOMpy/src
# Create the Conda environment from the environment.yml file
RUN /bin/bash -c "source $CONDA_DIR/etc/profile.d/conda.sh && conda env create -f environment.yml"

# Activate the Conda environment and install CEASIOMpy
RUN /bin/bash -c "source $CONDA_DIR/etc/profile.d/conda.sh && conda activate ceasiompy && pip install -e ."

# Automatically activate the Conda environment in new shells
RUN echo "source $CONDA_DIR/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate ceasiompy" >> ~/.bashrc && \
echo "pip install -e ." >> ~/.bashrc && \
echo "ceasiompy_run --gui" >> ~/.bashrc

# Move the content of /INSTALLDIR to the mounted /CEASIOMpy/INSTALLDIR folder at runtime
Expand Down
2 changes: 0 additions & 2 deletions ceasiompy/utils/tests/tests_workflowclasses/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions ceasiompy/utils/tests/tests_workflowclasses/ceasiompy.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies:
- shapely==2.1.0
- smt==2.9.2
- stpyvista==0.1.4
- streamlit==1.44.1
- streamlit==1.45.1
- streamlit-autorefresh
- vtk==9.3.0
- scikit-optimize==0.10.2
16 changes: 3 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import platform
import setuptools
from pathlib import Path

Expand All @@ -15,17 +14,8 @@
REQUIRES_PYTHON = ">=3.11.11"
REQUIRED = ["numpy"]
README = "README.md"
PACKAGE_DIR = "."
PACKAGE_DIR = "src"
LICENSE = "LICENSE"
SCRIPTS = [str(Path("src/bin/ceasiompy_exec.py"))]

# Windows
if platform.system().lower() == "windows":
# Use BAT file as wrapper, see file header for reason
SCRIPTS.append(str(Path("src/bin/ceasiompy_run.bat")))
# Linux and MacOs
else:
SCRIPTS.append(str(Path("src/bin/ceasiompy_run")))

here = Path(__file__).parent

Expand All @@ -45,9 +35,9 @@
url=URL,
include_package_data=True,
package_dir={"": PACKAGE_DIR},
scripts=SCRIPTS,
entry_points={'console_scripts': ['ceasiompy_run = CEASIOMpyStreamlit.cli:main_exec']},
license=license,
packages=setuptools.find_packages(exclude=EXCLUDE_DIRS),
packages=setuptools.find_packages(where=PACKAGE_DIR, exclude=EXCLUDE_DIRS),
python_requires=REQUIRES_PYTHON,
install_requires=[],
# See: https://pypi.org/classifiers/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import streamlit as st
import plotly.graph_objects as go

from src.streamlit.streamlitutils import create_sidebar
from CEASIOMpyStreamlit.streamlitutils import create_sidebar

from stl import mesh
from pathlib import Path
Expand Down
96 changes: 96 additions & 0 deletions src/CEASIOMpyStreamlit/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""Running CEASIOMpy script."""

import os
import sys
import subprocess

from pathlib import Path


def find_project_root():
current = os.getcwd()
while current != '/':
if 'setup.py' in os.listdir(current):
return current
current = os.path.dirname(current)
raise RuntimeError("Project root directory not found at " + os.getcwd())


def main_exec():
"""
Entry point function for the run_ceasiompy command.

This function executes the ceasiompy_exec.py script located
in src/bin within the project root, setting the working directory
to the project root and passing along all command-line arguments.
"""
# Define the absolute path to the project root based on the Docker mount.
PROJECT_ROOT = Path(find_project_root())

# Define the path to the ceasiompy_exec.py script relative to the project root.
SCRIPT_RELATIVE_PATH = Path("src") / "bin" / "ceasiompy_exec.py"
SCRIPT_ABSOLUTE_PATH = PROJECT_ROOT / SCRIPT_RELATIVE_PATH

# --- Validation ---

if not PROJECT_ROOT.is_dir():
print(f"Error: Project root directory not found at {PROJECT_ROOT}", file=sys.stderr)
sys.exit(1)

if not SCRIPT_ABSOLUTE_PATH.is_file():
print(f"Error: Script not found at {SCRIPT_ABSOLUTE_PATH}", file=sys.stderr)
sys.exit(1)

# --- Prepare Command ---

# Get arguments passed to this entry point (sys.argv[0] is the command name)
# We pass all arguments from index 1 onwards to the subprocess
script_args = sys.argv[1:]

# Construct the command to run
# Use sys.executable to ensure we use the python interpreter from the current environment
command = [sys.executable, str(SCRIPT_ABSOLUTE_PATH)] + script_args

# Set PYTHONPATH to include src/
env = os.environ.copy()
src_path = str(PROJECT_ROOT / "src")
env["PYTHONPATH"] = src_path + os.pathsep + env.get("PYTHONPATH", "")

# --- Execute Script ---

try:
# Use subprocess.run to execute the command
# cwd: Set the current working directory for the command to the project root
# check=True: Raise a CalledProcessError if the script returns a non-zero exit code
subprocess.run(command, cwd=PROJECT_ROOT, check=True, env=env)

# Deal with exceptions
except FileNotFoundError:
msg = (
"Error: Python interpreter or script not found. "
f"Command: {' '.join(map(str, command))}"
)
print(msg, file=sys.stderr)
sys.exit(1) # Indicate failure

except subprocess.CalledProcessError as e:
# This happens if the ceasiompy_exec.py script exits with an error code
print(
f"Error executing script: The script returned a non-zero exit code {e.returncode}.",
file=sys.stderr
)

if e.stdout:
print("--- Script stdout ---\n", e.stdout.decode(), file=sys.stderr)

if e.stderr:
print("--- Script stderr ---\n", e.stderr.decode(), file=sys.stderr)

sys.exit(e.returncode) # Exit the entry point with the script's error code

except Exception as e:
# Catch any other unexpected errors
print(f"An unexpected error occurred during script execution: {e}", file=sys.stderr)
sys.exit(1) # Indicate failure

sys.exit(0) # Indicate success
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import pandas as pd
import streamlit as st

from src.streamlit.streamlitutils import save_cpacs_file
from CEASIOMpyStreamlit.streamlitutils import save_cpacs_file
from cpacspy.cpacsfunctions import (
get_string_vector,
get_value_or_default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

from cpacspy.cpacsfunctions import get_value_or_default
from ceasiompy.utils.geometryfunctions import get_aircrafts_list
from src.streamlit.streamlitutils import section_edit_aeromap
from CEASIOMpyStreamlit.streamlitutils import section_edit_aeromap
from ceasiompy.utils.moduleinterfaces import get_specs_for_module
from src.streamlit.guiobjects import (
from CEASIOMpyStreamlit.guiobjects import (
int_vartype,
list_vartype,
bool_vartype,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

import streamlit as st

from src.streamlit.moduletab import add_module_tab

from CEASIOMpyStreamlit.moduletab import add_module_tab
from streamlitutils import (
create_sidebar,
save_cpacs_file,
Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions src/bin/CEASIOMpy.command

This file was deleted.

17 changes: 15 additions & 2 deletions src/bin/ceasiompy_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import os
import argparse
import subprocess

from pathlib import Path
from ceasiompy.utils.workflowclasses import Workflow
Expand All @@ -27,7 +28,6 @@
from unittest.mock import patch

from ceasiompy.utils.commonpaths import (
CEASIOMPY_PATH,
STREAMLIT_PATH,
TEST_CASES_PATH,
CPACS_FILES_PATH,
Expand Down Expand Up @@ -163,14 +163,27 @@ def run_gui():
"""Create an run a workflow from a GUI."""

log.info("CEASIOMpy has been started from the GUI.")
os.system(f"cd {STREAMLIT_PATH} && streamlit run CEASIOMpy.py")
env = os.environ.copy()
# Add the src directory to PYTHONPATH
env["PYTHONPATH"] = (
str(Path(__file__).resolve().parents[2] / "src")
+ os.pathsep
+ env.get("PYTHONPATH", "")
)
subprocess.run(
["streamlit", "run", "CEASIOMpy.py"],
cwd=STREAMLIT_PATH,
check=True,
env=env,
)

# =================================================================================================
# MAIN
# =================================================================================================


def main():

parser = argparse.ArgumentParser(
description="CEASIOMpy: Conceptual Aircraft Design Environment",
usage=argparse.SUPPRESS,
Expand Down
1 change: 0 additions & 1 deletion src/bin/ceasiompy_run

This file was deleted.

43 changes: 0 additions & 43 deletions src/bin/ceasiompy_run.bat

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading