Skip to content

Python: restructure internal packages and modules - #5558

Merged
helderco merged 4 commits into
dagger:mainfrom
helderco:sdk/python/module-restructure
Aug 3, 2023
Merged

helderco merged 4 commits into
dagger:mainfrom
helderco:sdk/python/module-restructure

Conversation

@helderco

@helderco helderco commented Aug 2, 2023 •

Copy link
Copy Markdown
Contributor

What?

This is a restructure of internal packages and modules in the Python SDK, mainly to rename many to private, and secondly to improve organization. This makes it clearer that they're not part of the "public API" of the library.

Reference docs

Additionally, this also updates the reference docs with a few long standing issues.

Compatibility

This doesn't change anything that was considered public API of the library (imported in __init__.py, present in reference docs), but it'll likely break users who are importing internal modules. The change makes it clearer what is considered internal due to the leading _ (underscore) in module names.

Example:

-from dagger.engine.conn import Engine
+from dagger._engine.conn import Engine

Some users may have been misled by the imports in the reference docs (before PR):

Screenshot 2023-08-02 at 18 19 50

The full path is now dagger.client.gen.Container, however we've always advised towards simply dagger.Container. The reference documentation has been updated to reflect this and hopefully avoid confusion (with this PR):

Screenshot 2023-08-02 at 18 20 03

Signed-off-by: Helder Correia <[email protected]>
@helderco helderco added the kind/breaking Breaking Change label Aug 2, 2023
@helderco

helderco commented Aug 2, 2023

Copy link
Copy Markdown
Contributor Author

I'm aware there's an issue with the provisioning download test when more than 4 are run concurrently. This can be reviewed in the meantime.

@gerhard
gerhard requested review from gerhard and grouville August 2, 2023 18:55
@gerhard gerhard assigned helderco and unassigned gerhard and grouville Aug 2, 2023

@gerhard gerhard left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I went through all the files, the changes look good to me.

Apart from the 2 failing checks, I will run the cowsay example, then throw in a few twists and check if everything works as expected.

This is how far I was able to get:

import sys
sys.path.append('./src')

import anyio
import dagger


async def main(args: list[str]):
    async with dagger.Connection() as client:
        # build container with cowsay entrypoint
        ctr = (
            client.container()
            .from_("python:alpine")
            .with_exec(["pip", "install", "cowsay"])
            .with_entrypoint(["cowsay"])
        )

        # run cowsay with requested message
        result = await ctr.with_exec(args).stdout()

    print(result)


anyio.run(main, sys.argv[1:])

Then had to setup a dev Engine:

# at the top level:
./hack/dev
export _EXPERIMENTAL_DAGGER_CLI_BIN=/Users/gerhard/github.com/dagger/dagger/bin/dagger
export _EXPERIMENTAL_DAGGER_RUNNER_HOST=docker-container://dagger-engine.dev

And then just python main.py "foo"

python-main.py.mp4

@helderco

helderco commented Aug 2, 2023

Copy link
Copy Markdown
Contributor Author

Not the first time I assigned instead of requesting review 😅

@gerhard

gerhard commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

It's been a long week, I know 💪

@gerhard gerhard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stopping for the day & don't want to stall this anymore than necessary.

LGTM 💪

Signed-off-by: Helder Correia <[email protected]>
@helderco

helderco commented Aug 3, 2023 •

Copy link
Copy Markdown
Contributor Author

@gerhard the failed provision tests are due to the path to _version.py having changed which triggered the provisioning tests that usually only run on merge to main or when cli/engine is released. So it's not running the dev engine here and is missing an API field (version compatibility check).

The provision tests are too expensive to run on every PR, they're run less often but still early enough to catch something so we can fix before release. Which means, the simplest thing here is to just merge with these provision failures. When merged to main, a new engine is released and that'll have the missing api field that the test will then use.

@helderco
helderco merged commit ca09a8a into dagger:main Aug 3, 2023
@helderco
helderco deleted the sdk/python/module-restructure branch August 3, 2023 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/breaking Breaking Change

Projects

None yet

3 participants