-
Notifications
You must be signed in to change notification settings - Fork 14
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
Amoz pay docker support #114
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,22 @@ | |||
[[source]] |
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.
src/aleph_client/__main__.py
Outdated
@@ -373,6 +376,168 @@ def program( | |||
asyncio.run(get_fallback_session().close()) | |||
|
|||
|
|||
|
|||
# TODO: find an appropirate name |
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.
pirate ? 🦜
src/aleph_client/__main__.py
Outdated
def container( | ||
image: str = typer.Argument(..., help="Path to an image archive exported with docker save."), | ||
path: str = typer.Argument(..., metavar="SCRIPT", help="A small script to start your container with parameters"), | ||
remote: bool = typer.Option(False, "--remote", "-r", help=" If --remote, IMAGE is a registry to pull the image from. e.g: library/alpine, library/ubuntu:latest"), |
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.
What about naming this --from-remote
?
src/aleph_client/__main__.py
Outdated
|
||
# TODO: find an appropirate name | ||
@app.command() | ||
def container( |
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.
Using the namespace from #111 would be useful here. Not blocking.
src/aleph_client/__main__.py
Outdated
# image = image_archive | ||
# print(manifest) | ||
echo("Preparing image for vm runtime") | ||
docker_data_path = os.path.abspath("docker-data") |
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.
What is this docker-data
directory ?
src/aleph_client/__main__.py
Outdated
path = os.path.abspath(path) | ||
entrypoint = path | ||
|
||
# Create a zip archive from a directory |
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.
A first PR to move the code out of program()
and remove duplication, then a second with the container specific code ?
src/aleph_client/docker/image.py
Outdated
def __load_metadata(self, tar: TarFile, file: str) -> Dict[str, str]: | ||
return json.load(tar.extractfile(file)) | ||
|
||
def __init__(self, path: str): |
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 not use pathlib.Path
?
src/aleph_client/docker/image.py
Outdated
self.diff_ids = self.config["rootfs"]["diff_ids"] | ||
self.chain_ids = self.__compute_chain_ids() | ||
|
||
def __compute_chain_ids(self) -> List[str]: |
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 two underscores __
? Why is this a method and not a separate function ?
See https://peps.python.org/pep-0008/#descriptive-naming-styles
src/aleph_client/docker/image.py
Outdated
|
||
# I used recursion because it was simpler to execute, not because it's better | ||
# cause it's not. TODO: use iteration | ||
def recursive_compute_chain_id(index: int) -> str: |
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.
Recursion can be OK, but having functions not reachable from the outside because they only exist within another function makes them very difficult to test.
Solution: put all commands in a sub folder and use typer subcommands Use typer.Option and typer.Argument to document each command parameter
Solution: put all commands in a sub folder and use typer subcommands Use typer.Option and typer.Argument to document each command parameter
Solution: Pull image using API and reproduce docker data dir
…\nSolution: Use function rather than class method depending on self + use iteration rather than recursion
20b6265
to
9c547ab
Compare
Solution: Create a new subcommand, "aleph container create"
9c547ab
to
a7c81bf
Compare
Solution: Create two different output files in the output directory
No description provided.