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

Local annotations setup and minor dependency handling #750

Open
wants to merge 6 commits into
base: future
Choose a base branch
from

Conversation

DivikChotani
Copy link

  • Modified pa.sh for compatibility with local annotations
  • Added local-annotations-library-documentation.md with setup instructions
  • Introduced local-or-pypi.sh to configure package installation mode for local annotations

Signed-off-by: Divik Chotani [email protected]

angelhof and others added 2 commits November 18, 2024 16:54
- Modified `pa.sh` for compatibility with local annotations
- Added `local-annotations-library-documentation.md` with setup instructions
- Introduced `local-or-pypi.sh` to configure package installation mode for local annotations

Signed-off-by: Divik Chotani [email protected]
Signed-off-by: Divik Chotani <[email protected]>
Copy link
Member

@angelhof angelhof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the changes Divik :) Here are some comments that you can address before we look at this again. Two more things:

  1. You should retarget this PR to go to future instead of main.
  2. You should add a test of this process, this could be next to the other tests that PaSh runs and then add this test to CI too (check how to add CI tests here: https://github.com/binpash/pash/blob/main/.github/workflows/tight-loop.yaml)

@@ -0,0 +1,83 @@
# PaSh Setup and Execution Guide
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be moved under docs and we should add a pointer sentence to it from the README :)

If you haven't already cloned PaSh, do so with:

```sh
git clone https://github.com/binpash/pash.git ~/pash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to clone it in ~/pash, you can just say

git clone https://github.com/binpash/pash.git
cd pash




Do not forget to export before using pash: `export PASH_TOP=/home/your-username/pash`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be changed to the directory that pash is stored, no need to specify it here :)

To make this persistent across terminal sessions, add it to your shell configuration file:

```sh
echo 'export PASH_TOP=/home/your-username/pash >> ~/.bashrc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing single quote here

```

This will:
- Check if `~/annotations` exists.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally it should also take an annotation repository as a path (or assume it is a sibling to PaSh but not that it is in the home directory).

local-or-pypi.sh Outdated
graphviz
libdash
pash-annotations==0.2.2
shasta==0.1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to rewrite these here, we better just take them from the requirements file

local-or-pypi.sh Outdated
exit 1
fi

echo "✅ Requirements file updated successfully."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this file should instead not change the requirement but rather install the local annotations repo. That makes me wonder whether it should be a part of setup-pash.sh and install local annotations when passed a specific flag, like --local-annotations.

pa.sh Outdated
@@ -3,7 +3,10 @@
export PASH_TOP=${PASH_TOP:-${BASH_SOURCE%/*}}
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/"
# point to the local downloaded folders
export PYTHONPATH=$PASH_TOP/venv/lib/python3.12/site-packages:$PYTHONPATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary or can the use of venv be split in a different PR?

pa.sh Outdated
export PYTHONPATH="${PASH_TOP}/python_pkgs/:${PYTHONPATH}"
export PYTHONPATH=~/annotations:$PYTHONPATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too hardcoded. Maybe the default value is next to the pash directory (sibling of PaSh top).

requirements.txt Outdated
shasta==0.1.0
sh-expand>=0.1.6
-e /home/divikchotani.linux/annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't look right :)

- Modified `pa.sh` for compatibility with local annotations
- Added `local-annotations-library-documentation.md` with setup instructions
- Introduced `setup-local.sh` to configure package installation mode for local annotations

Signed-off-by: Divik Chotani <[email protected]>
@DivikChotani DivikChotani force-pushed the local-annotations-library branch from af58d6e to cccca4e Compare February 28, 2025 10:41
@DivikChotani DivikChotani changed the base branch from main to future February 28, 2025 10:50
@@ -0,0 +1 @@
/home/divikchotani.linux/annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be git-ignored!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or completely removed since it is not used anymore

@@ -4,6 +4,24 @@ export PASH_TOP=${PASH_TOP:-${BASH_SOURCE%/*}}
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/"
# point to the local downloaded folders
export PYTHONPATH="${PASH_TOP}/python_pkgs/:${PYTHONPATH}"
export ANNOTATIONS_PATH=$([ -f "$PASH_TOP/local-annotations-path.txt" ] && tr -d '[:space:]' < "$PASH_TOP/local-annotations-path.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see where you are going with this but it is very scary and a very big dependency for PaSh. I think the most appropriate way would be to modify PaSh's installation (scripts/setup_pash.sh) to copy the annotation repo in the right place. I could see two ways to do this:

  1. Either create a small installation script that replaces the annotation repo where pash looks for dependencies (https://github.com/binpash/pash/blob/future/scripts/setup-pash.sh#L37) and call it there (https://github.com/binpash/pash/blob/future/scripts/setup-pash.sh#L37). Then everytime the user modifies the annotation repo they will call this script and replace their local version of annotations. If we do that we also need to create a script that redownloads the latest normal annotations if needed.
  2. Properly add a new --local-annotations-dir option to PaSh (https://github.com/binpash/pash/blob/future/compiler/orchestrator_runtime/pash_init_setup.sh#L27) which could be used to update PYTHONPATH to point first to where the local annotation library is. I think this is the preferred solution if it works :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the changes in pa.sh now? I think we should delete all of them, I don't see why they are necessary.

@angelhof
Copy link
Member

I left some more suggestions for changes. Once these are done, it would also be great to check that this works. That is why adding a test in CI would be great to guarantee we never break this. To do this, we would add a CI file similar to this: https://github.com/binpash/pash/blob/future/.github/workflows/tight-loop.yaml where we download and install pash (similar to this CI file), and then

  1. download annotation library
  2. add a new annotation
  3. execute a script that uses this annotation and assert that it succeeds

I understand that this is a lot of work, so this could become a different PR. Let's try to fix the current issues now and merge this PR and then we can see how to make this work.

- Implemented `--local-annotations-dir` to allow dynamic switching of annotation.
- Updated `pash_init_setup.sh` to adjust `PYTHONPATH` based on user input.
- Allowed `cli.py` to recognize and prioritize local annotations when provided.
- Ensured clean handling of `requirements.txt`, avoiding unnecessary modifications.

Signed-off-by: Divik Chotani [email protected]
Signed-off-by: Divik Chotani <[email protected]>
- Resolved merge conflicts between remote and local

Signed-off-by: Divik Chotani [email protected]
Signed-off-by: Divik Chotani <[email protected]>
Copy link

OS:ubuntu-20.04
Fri Feb 28 20:49:03 UTC 2025
intro: 2/2 tests passed.
interface: 42/42 tests passed.
compiler: 54/54 tests passed.

Copy link

OS:ubuntu-24.04
Fri Feb 28 20:49:07 UTC 2025
intro: 2/2 tests passed.
interface: 41/42 tests passed.
compiler: 52/54 tests passed.
test_set are not identical
tr-test.sh are not identical
tr-test.sh are not identical

Copy link
Member

@angelhof angelhof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, please carefully address the changes that I marked here and let me know if you need more context for any of them :)

done

## `pash_redir_output` and `pash_redir_all_output` are strictly for logging.
##
## They do not execute their arguments if there is no debugging.
if [ "$local_annotations" -eq 1 ]; then
# Comment out the PyPI-installed `pash-annotations`
sed -i 's/^pash-annotations.*/#&/' "$PASH_TOP/requirements.txt"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do that? At this point is anyone reading the requirements.txt?


if [ "--local-annotations-dir" == "$item" ]; then
shift
export ANNOTATIONS_PATH=$(realpath "$2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it surprising that this works with $2 here...


You can also run the full PaSh test suite:
```sh
$PASH_TOP/evaluation/tests/test_evaluation_scripts.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't run the PaSh test suite with the local annotations, why do you mention it then?

@@ -0,0 +1 @@
/home/divikchotani.linux/annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or completely removed since it is not used anymore

@@ -4,6 +4,24 @@ export PASH_TOP=${PASH_TOP:-${BASH_SOURCE%/*}}
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/"
# point to the local downloaded folders
export PYTHONPATH="${PASH_TOP}/python_pkgs/:${PYTHONPATH}"
export ANNOTATIONS_PATH=$([ -f "$PASH_TOP/local-annotations-path.txt" ] && tr -d '[:space:]' < "$PASH_TOP/local-annotations-path.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the changes in pa.sh now? I think we should delete all of them, I don't see why they are necessary.

## **🔹 Step 3: Run setup-annotations.sh to Configure Package Installation**
PaSh provides a script to configure dependencies, including an option to install local annotations.

To install dependencies normally:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a typo?

ANNOTATIONS_PATH=$(realpath "$ANNOTATIONS_DIR")
echo $ANNOTATIONS_PATH > local-annotations-path.txt
echo "✅ Annotations repository cloned to: $ANNOTATIONS_PATH"
grep -qxF "$ANNOTATIONS_PATH" requirements.txt || echo -e "\n-e $ANNOTATIONS_PATH" >> requirements.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we modify requirements here? Why is this useful?

@@ -215,6 +215,14 @@ def __init__(self, *args, **kwargs):
help=" output the preprocessed script",
action="store_true",
)
self.add_argument(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only useful for the help message, other than that the parsing of the argument just happens outside in pash_init_setup.sh so I am not sure whether all of these options (like nargs, const) are useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants