-
Notifications
You must be signed in to change notification settings - Fork 16
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
Setup docker template access to EFS #302
Setup docker template access to EFS #302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be in sds-data-manager? You have AWS information here, and the processing repository should be agnostic to any AWS work and able to be run locally.
I'm not following why we need all these steps... pip install imap_processing
should get us all the scripts we need to do any processing steps. So it should be a 2-3 line Dockerfile I'd hope. (You can also remove the install git if you change to install from a zip archive for now)
- The script should be installed and accessed as
imap_processing --flags
. - If
tools/
are needed during processing, then those should probably be moved up into the main package to get their dependencies automatically?
Dockerfile
Outdated
|
||
# Copy over only the necessary scripts | ||
COPY imap_processing/run_processing.py $IMAP_PROCESS_DIRECTORY/run_processing.py | ||
COPY tools $IMAP_PROCESS_DIRECTORY/tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to copy tools
folder? I think it's only used locally to create XTCE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the example I had of how to use the kernels, which is what I was using the tools folder for. But I removed the example.
Dockerfile
Outdated
RUN pip install git+https://github.com/IMAP-Science-Operations-Center/imap_processing.git@dev | ||
|
||
# Copy over only the necessary scripts | ||
COPY imap_processing/run_processing.py $IMAP_PROCESS_DIRECTORY/run_processing.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should come in the pip package. If it didn't, we could find out why.
Dockerfile
Outdated
RUN mkdir -p /mnt/spice | ||
|
||
# Define the entrypoint of the container | ||
ENTRYPOINT ["python", "/opt/imap/run_processing.py"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested it but I wonder if you could change this to the pip path. Then you won't need to copy in above line.
ENTRYPOINT ["python", "/opt/imap/run_processing.py"] | |
ENTRYPOINT ["python", "<pip path>/imap_processing/run_processing.py"] |
I believe you can get by doing pip show imap_processing
To build the image run the following command from the directory containing the Dockerfile. You might add -t option to tag your image | ||
and --rm to remove intermediate containers after the build is done. | ||
|
||
`docker build -t <image name> --rm .` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`docker build -t <image name> --rm .` | |
`docker build -t <image name>:<tag name> --rm .` |
|
||
Now we can run our image. | ||
|
||
`docker run --rm -it --volume="$(pwd)/imap_processing/efs:/mnt/spice" <image name> --instrument <instrument> --level <level>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`docker run --rm -it --volume="$(pwd)/imap_processing/efs:/mnt/spice" <image name> --instrument <instrument> --level <level>` | |
`docker run --rm -it --volume="$(pwd)/imap_processing/efs:/mnt/spice" <image name>:<tag name> --instrument <instrument> --level <level>` |
Build the Docker image. | ||
|
||
`docker build -t <image name> .` | ||
|
||
Tag the image and push to the ECR. | ||
|
||
`docker tag <tag> <ECR URI>` | ||
|
||
`docker push <ECR URI>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the place where we would set image tag with version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can assign the tag name during the build :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me. Thank you!
@@ -36,11 +37,10 @@ def _parse_args(): | |||
f"The data level to process. Acceptable values are: {processing_levels}" | |||
) | |||
|
|||
parser = argparse.ArgumentParser(description=description) | |||
parser = argparse.ArgumentParser(prog="imap_cli", description=description) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering what this was but looks like it was from poetry. cool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, since this is mostly documentation at this point I'm fine with keeping it in this repository since it is more public-facing. But, I think the Dockerfile should be moved out of our base repository level.
imap_processing/cli.py
Outdated
@@ -7,17 +7,18 @@ | |||
|
|||
Use | |||
--- | |||
python run_processing.py <instrument> <data_level> | |||
python cli.py <instrument> <data_level> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imap_cli --instrument <instrument> --level <data_level>
@@ -162,11 +162,12 @@ def process(self): | |||
print(f"Processing IMAP-Ultra {self.level}") | |||
|
|||
|
|||
if __name__ == "__main__": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need the if __name__ == "__main__" call main() block for running it as
python cli.py` So it is best to leave that in there for either option.
Dockerfile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this doesn't live at the root level. Maybe move it into an examples/
folder?
Also perhaps call it some_unique_name.Dockerfile
or Dockerfile.some_unique_name
so it isn't just a base Dockerfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clear explanations and descriptions, I think this is nice with the explicit example.
I would still like to see the cli_args
removed if that isn't actually needed/used.
imap_processing/cli.py
Outdated
|
||
from imap_processing import instruments, processing_levels | ||
|
||
|
||
def _parse_args(): | ||
def _parse_args(cli_args: list): |
There was a problem hiding this comment.
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 cli_args
here and in main()
? I was pretty sure in my testing that there was not extra args passed into the script's main function call...
https://docs.python.org/3/library/argparse.html#parsing-arguments
In a script, parse_args() will typically be called with no arguments, and the ArgumentParser will automatically determine the command-line arguments from sys.argv.
To build the image run the following command from the directory containing the Dockerfile. You might add -t option to tag your image | ||
and --rm to remove intermediate containers after the build is done. | ||
|
||
`docker build -t <image name>:<tag name> --rm .` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to give an example of how to build the image you added? You'll need the -f Dockerfile.name
now because it isn't the default Dockerfile (sorry for the misdirection there)!
`docker build -t <image name>:<tag name> --rm .` | |
`docker build -f examples/Dockerfile.efs -t <image name>:<tag name> --rm .` |
62b3703
into
IMAP-Science-Operations-Center:dev
@all-contributors please add @laspsandoval for infrastructure and ideas |
I've put up a pull request to add @laspsandoval! 🎉 |
* Setup docker template access to EFS
Change Summary
Overview
Sets up docker template that can be used to push images to the ECR, provides instructions of how to do that, and provides access to EFS containing SPICE kernels.
New Files
Deleted Files
None
Updated Files
Testing