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

Amoz pay docker support #114

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

Amoz pay docker support #114

wants to merge 9 commits into from

Conversation

AmozPay
Copy link
Contributor

@AmozPay AmozPay commented Oct 13, 2022

No description provided.

@@ -0,0 +1,22 @@
[[source]]
Copy link
Member

Choose a reason for hiding this comment

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

See " Choose between Pipfile and setup.cfg #76" #76

@@ -373,6 +376,168 @@ def program(
asyncio.run(get_fallback_session().close())



# TODO: find an appropirate name
Copy link
Member

Choose a reason for hiding this comment

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

pirate ? 🦜

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"),
Copy link
Member

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 ?


# TODO: find an appropirate name
@app.command()
def container(
Copy link
Member

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.

# image = image_archive
# print(manifest)
echo("Preparing image for vm runtime")
docker_data_path = os.path.abspath("docker-data")
Copy link
Member

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 ?

path = os.path.abspath(path)
entrypoint = path

# Create a zip archive from a directory
Copy link
Member

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 ?

def __load_metadata(self, tar: TarFile, file: str) -> Dict[str, str]:
return json.load(tar.extractfile(file))

def __init__(self, path: str):
Copy link
Member

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 ?

self.diff_ids = self.config["rootfs"]["diff_ids"]
self.chain_ids = self.__compute_chain_ids()

def __compute_chain_ids(self) -> List[str]:
Copy link
Member

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


# 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:
Copy link
Member

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.

AmozPay and others added 7 commits November 17, 2022 15:04
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
Solution: Create a new subcommand, "aleph container create"
Solution: Create two different output files in the output directory
@MHHukiewitz MHHukiewitz self-assigned this Nov 23, 2023
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.

3 participants