From 46ced2cfd3e3ab520aac264eb8d8dabc30b46e98 Mon Sep 17 00:00:00 2001 From: Douglas R Miles Date: Wed, 14 Feb 2024 19:20:19 -0800 Subject: [PATCH] really got #2 fixed maybe --- .bash_history | 39 ++++-------------------- Dockerfile | 10 +++---- INSTALL.sh | 1 + metta_vspace/pyswip/metta_interp.pl | 4 +-- mettalog | 46 +++++++++++++++++++++-------- 5 files changed, 46 insertions(+), 54 deletions(-) diff --git a/.bash_history b/.bash_history index b873a9a..880a931 100644 --- a/.bash_history +++ b/.bash_history @@ -1,37 +1,3 @@ -cd /opt/logicmoo_workspace/packs_sys/logicmoo_opencog/MeTTa/vspace-metta/ -./MeTTa --v_2a examples/interp_2a/ -./MeTTa --v_3y examples/interp_3y/ -./scripts/test_in_metta.sh -n --report=Y -git add reports/ -cp pyswip/metta_reader.pl pyswip_3y/ -cd .. -./scripts/test_in_metta.sh -n --report=Y -./MeTTa examples/interp_88 -git add reports/ -git status examples/ -git add examples/ -git status examples/ -./scripts/test_in_metta.sh -n --report=Y -git status . -git add metta_vspace/pyswip_2a/ -git add metta_vspace/pyswip_3y -git add metta_vspace/pyswip/ -ls reports/cuRRent/interp_88/hyperon-pln_metta/entail/ -./scripts/test_in_metta.sh -n --report=Y -ls reports/cuRRent/interp_88/hyperon-pln_metta/entail/ -git add reports/ -git status . -git add etta_vspace/pyswip_1/ -git add metta_vspace/pyswip_1/ -git add metta_vspace/pyswip_1 -git add -U metta_vspace/pyswip_1 -git add -u metta_vspace/pyswip_1 -git add -u metta_vspace/pyswip_1/ -git status . -git add reports/ -./scripts/test_in_metta.sh -n --report=Y -./MeTTa examples/interp_88 --clean -git add reports/ git add git status . git status . git commit -am reports/cuRRent @@ -2027,3 +1993,8 @@ git checkout 586ef99b9703c3910df3c5f2bb9478a50ef442c3 Dockerfile git diff 586ef99b9703c3910df3c5f2bb9478a50ef442c3 Dockerfile git checkout 586ef99b9703c3910df3c5f2bb9478a50ef442c3 Dockerfile git commit -am ENV PATH="${PATH}:${MATTALOG_DIR}" +git commit -am 'ENV PATH="${PATH}:${MATTALOG_DIR}"' +git push +docker build . -t mettalog +docker build . -t mettalog +docker build . -t mettalog diff --git a/Dockerfile b/Dockerfile index cf9ac58..09857bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,21 +44,21 @@ WORKDIR ${HOME} # Install MeTTaLog -ENV MATTALOG_DIR="${HOME}/vspace-metta" +ENV METTALOG_DIR="${HOME}/vspace-metta" +ENV PATH="${PATH}:${METTALOG_DIR}" WORKDIR ${HOME} RUN git clone https://github.com/logicmoo/vspace-metta.git -WORKDIR ${MATTALOG_DIR} +WORKDIR ${METTALOG_DIR} # This COPY is in case we have made local changes # so we dont have to commit to Github to test them out COPY ./INSTALL.sh ./INSTALL.sh - -ENV PATH="${PATH}:${MATTALOG_DIR}" - RUN ./INSTALL.sh --easy # This COPY is in case we have made local changes # so we dont have to commit to Github to test them out +#COPY ./ ${METTALOG_DIR}/ +#COPY ./metta_vspace/pyswip ${METTALOG_DIR}/metta_vspace/pyswip COPY ./ ./ diff --git a/INSTALL.sh b/INSTALL.sh index 0e390a1..a931c7b 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -321,6 +321,7 @@ check_metalog_in_path() { # Call the function to perform the check and update check_metalog_in_path +which swipl echo -e "${GREEN}Installation and setup complete!${NC}." diff --git a/metta_vspace/pyswip/metta_interp.pl b/metta_vspace/pyswip/metta_interp.pl index 2c6d023..2128574 100755 --- a/metta_vspace/pyswip/metta_interp.pl +++ b/metta_vspace/pyswip/metta_interp.pl @@ -2313,7 +2313,7 @@ ggtrace0(G):- ggtrace, leash(-all), visible(-all), - % debug, + % debug, %visible(+redo), visible(+call), visible(+exception), @@ -2350,7 +2350,7 @@ nop(load_history), set_prolog_flag(history, 3), (set_output_stream), - update_changed_files, + if_t(is_compiled,update_changed_files), run_cmd_args, maybe_halt(7)]))),!. diff --git a/mettalog b/mettalog index 7fd2028..ed7971b 100755 --- a/mettalog +++ b/mettalog @@ -138,27 +138,46 @@ function resolve_upward { done } -# if not already in docker +# Check if the script is running inside a Docker container if [ ! -f /.dockerenv ]; then - # The name of the Docker image you're looking to use + # Define the name of the Docker image IMAGE_NAME="mettalog" # Check if Docker is installed if command -v docker &> /dev/null; then # Check if the Docker image exists - if docker image inspect "$IMAGE_NAME" &> /dev/null ; then - DEBUG "Image $IMAGE_NAME is installed. Running command..." - # Run your command inside the Docker container - UPWARD=$(resolve_upward "$(pwd)") - # Run the Docker container with necessary volumes mounted - # Note: It's crucial to quote '$(pwd)' to handle spaces in the path - docker run --rm -it \ + if docker image inspect "$IMAGE_NAME" &> /dev/null; then + echo "Updating the Docker image: $IMAGE_NAME" + + # Create a temporary file to capture the build output + temp_file=$(mktemp) + + # Build the Docker image and redirect stderr to the temporary file + if ! docker build . -t "$IMAGE_NAME" > "$temp_file" 2>&1; then + echo "Docker build failed. Output:" + # Tail the last 30 lines of the build output for debugging + tail -30 "$temp_file" + # Clean up the temporary file + rm "$temp_file" + exit 1 + else + # If build succeeds, remove the temporary file + rm "$temp_file" + echo "Image $IMAGE_NAME successfully updated." + fi + + # Setup additional environment variables or paths + SCRIPT_DIR=$(dirname "$(readlink -f "$0")") + # Example: UPWARD=$(resolve_upward "$(pwd)") + + # Run the Docker container with the necessary volumes mounted + exec docker run -it \ -v "${SCRIPT_DIR}:/home/user/vspace-metta" \ - -v "${UPWARD}:${UPWARD}" \ - -v "$(pwd):/host/cwd" \ + -v "$(pwd):$(pwd)" \ -w "$(pwd)" \ - mettalog:latest \ - /home/user/vspace-metta/mettalog ${@} + "$IMAGE_NAME" \ + /home/user/vspace-metta/mettalog "$@" + else echo "Image $IMAGE_NAME is not installed. Continuing with script..." fi @@ -168,6 +187,7 @@ if [ ! -f /.dockerenv ]; then fi + quoted_args=() # Initialize an empty array to store the results for arg in "$@"; do # Check if the argument contains spaces, exclamation marks, backslashes, or quote characters