Skip to content

pipelines: merge dev module back into the root - #8042

Merged
jedevc merged 4 commits into
dagger:mainfrom
shykes:dev-dagger-module
Aug 9, 2024
Merged

jedevc merged 4 commits into
dagger:mainfrom
shykes:dev-dagger-module

Conversation

@shykes

@shykes shykes commented Jul 25, 2024 •

Copy link
Copy Markdown
Contributor

Context

-m dev is just too cumbersome. Meanwhile in the latest design discussions, we are moving away from the concept of "dev module". See this discord thread.

Since the prospect of a "quick win" where a dev module pattern solves all our problems is less and less certain, there's no point in incurring the pain of the extra -m dev at this point.

Summary

  • Main Dagger module is now github.com/dagger/dagger
  • No more github.com/dagger/dagger/dev (this breaks external references to these modules, which we intentionally discouraged because of anticipated changes like this one)
  • Sub-modules moved to the root of the repo (we didn't have sub-modules before)
  • The rest is in .dagger (better than ci)

TODO before merging

Remaining tasks:

  • fix CI help wanted
  • remove references to dev in Github Actions config in progress
  • Remove -m dev from SDK docs help wanted this is a different dev module, wontfix
  • Reach consensus on where to move sub-modules

TODO after merging

Where should sub-modules go?

This is was a contentious point, but we have consensus on modules/.

The modules in question:

Before After
github.com/dagger/dagger/dev/dirdiff github.com/dagger/dagger/modules/dirdiff
github.com/dagger/dagger/dev/go github.com/dagger/dagger/modules/go
github.com/dagger/dagger/dev/golangci github.com/dagger/dagger/modules/golangci
github.com/dagger/dagger/dev/graphql github.com/dagger/dagger/modules/graphql
github.com/dagger/dagger/dev/markdown github.com/dagger/dagger/modules/markdown
github.com/dagger/dagger/dev/ruff github.com/dagger/dagger/modules/ruff
github.com/dagger/dagger/dev/shellcheck github.com/dagger/dagger/modules/shellcheck
github.com/dagger/dagger/dev/wolfi github.com/dagger/dagger/modules/wolfi
github.com/dagger/dagger/dev/ps-analyzer github.com/dagger/dagger/modules/ps-analyzer

Options we discussed:

Option Example
top-level github.com/dagger/dagger/ruff
under modules ⭐ github.com/dagger/dagger/modules/ruff
under .dagger github.com/dagger/dagger/.dagger/ruff
spin out stdlib github.com/dagger/std/ruff
spin out CI module + submodules github.com/dagger/ci/ruff
spin out individual submodules github.com/dagger/ruff
"your (Go) house your (Go) rules" github.com/dagger/dagger/internal/ruff
"your (Python) house your (Python) rules" github.com/dagger/dagger/sdk/python/ruff
give up and revert everything github.com/dagger/dagger/dev

FAQ

Will this break external imports of github.com/dagger/dagger/dev/foo?

No, because dagger.json is pinned.

It will break dagger install commands that reference the module without a pinned tag or commit. It may also break a future dagger update command.

Given the limited exposure of the dev module to external imports (on purpose, as we anticipated future changes), I think there is no actual breakage to worry about.

Is .dagger really the right source directory?

It's better than ci... Let's try, and see how it feels. See also this discussion.

Isn't weird to have dagger sub-modules at the root of the repo? Like github.com/dagger/dagger/ruff...

This is a contentious point. See "where should sub-modules go"?

@shykes

shykes commented Jul 25, 2024 •

Copy link
Copy Markdown
Contributor Author

Here is why I had to disable sdk().python() from the main module. Can anyone reproduce this from a fresh checkout?

$ dagger install --name python-sdk-dev ./sdk/python/dev
Full trace at https://dagger.cloud/dagger/traces/1da44b623400f23f1489e9d42c7afe6e

✔ connect 0.8s
✔ moduleSource(refString: "."): ModuleSource! 0.0s
✔ ModuleSource.kind: ModuleSourceKind! 0.0s
✔ ModuleSource.resolveContextPathFromCaller: String! 0.0s
✔ moduleSource(refString: "./sdk/python/dev"): ModuleSource! 0.0s
✔ ModuleSource.kind: ModuleSourceKind! 0.0s
✔ moduleSource(refString: "sdk/python/dev"): ModuleSource! 0.0s
✔ moduleDependency(
    name: "python-sdk-dev"
    source: ✔ moduleSource(refString: "sdk/python/dev"): ModuleSource! 0.0s
  ): ModuleDependency! 0.0s
✔ ModuleSource.withDependencies(dependencies: [xxh3:2950ff247d28f4b3]): ModuleSource! 0.0s
✔ ModuleSource.resolveFromCaller: ModuleSource! 0.3s
✘ ModuleSource.asModule: Module! 0.0s
! failed to create module: select: failed to update module dependencies: module "dagger-dev" dependency "python-sdk-dev" with source root path "sdk/python/dev" does not exist or does not have a configuration file
Error: failed to generate code: input: moduleSource.withContextDirectory.withDependencies.asModule resolve: failed to create module: select: failed to update module dependencies: module "dagger-dev" dependency "python-sdk-dev" with source root path "sdk/python/dev" does not exist or does not have a configuration file

Note that ./sdk/python/dev exists, and is a valid module:

$ dagger -m ./sdk/python/dev functions
Full trace at https://dagger.cloud/dagger/traces/8624ba7bcbb62c339935cfbdf027430f

✔ connect 0.9s
✔ initialize 2.8s

Name                 Description
build                Build Python SDK package for distribution.
container            Container to run commands in
docs                 Preview the reference documentation.
format               Format source files.
generate             Generate the client bindings for the API.
lint                 Check for linting errors.
supported-versions   Supported Python versions.
test                 Run the test suite.
test-versions        Run the test suite for all supported versions.
typecheck            Run the type checker (mypy).
with-container       Replace container.
with-directory       Mount a directory on the base container.

If anyone has any idea... I am interested.

@grouville

Copy link
Copy Markdown
Member

Same behavior, checking 👀

@jedevc

jedevc commented Jul 25, 2024 •

Copy link
Copy Markdown
Contributor

I think the other 3 points make sense, those SGTM 🎉 Just a little caught up on moving all the helper modules to the top level.

I would rather we keep those in .dagger:

  • All the dagger code can live in one place, no need to jump around
  • It provides a logical distinction between the code I'm building and the code that builds
  • It's easier for new contributors to find all the dagger code - just look in the named .dagger folder, and it's all in there
  • It keeps the top-level from becoming cluttered - I often use the directory view to navigate the repo (I suspect I'm not entirely alone) and so it's nice to keep each level as small as possible.

I suspect there's a reason for moving them up - I'm guessing it's nicer for non dagger callers to access it using github.com/dagger/dagger/shellcheck instead of github.com/dagger/dagger/ci/shellcheck or similar. But if that's the goal, I'd argue that those modules aren't actually ready to be consumed by external callers - and if they are, we should be using them as external callers ourselves, and move them into github.com/dagger/std or similar - that way we can dogfood the experience ourselves.

Is there another reason we should move them up? I think that's probably the most controversial thing I can see in this PR, just off a quick glance, but if the aim is to merge quickly and iterate, potentially we could split that out and discuss that one separately - the other parts SGTM 🎉

(I'm not 100% sure about .dagger, but I'm willing to try it for a bit, it does really clearly label where to look for dagger code, and I'm a big fan of that kind of explicit signposting)

@shykes

shykes commented Jul 25, 2024

Copy link
Copy Markdown
Contributor Author

Is there another reason we should move them up?

Nope, having them importable at a sane address is indeed the main reason.

But if that's the goal, I'd argue that those modules aren't actually ready to be consumed by external callers - and if they are, we should be using them as external callers ourselves, and move them into github.com/dagger/std or similar - that way we can dogfood the experience ourselves.

Or, let's dogfood the experience of having importable submodules in the same repo, like I'm proposing here. Our users will encounter this situation so we should make sure it works well. Spinning out into a separate repo can happen later. To do it now would be rushing it.

if the aim is to merge quickly and iterate, potentially we could split that out and discuss that one separately

Not ideal in this case, I really don't want to leave a trail of modules imported at github.com/dagger/dagger/.dagger/foo

I'm not 100% sure about .dagger, but I'm willing to try it for a bit, it does really clearly label where to look for dagger code, and I'm a big fan of that kind of explicit signposting

I also tried an alternative: internal/dagger/main but it got confusing. Still viable IMO but requires merging go modules (to avoid 2 levels of internal modules aka github.com/dagger/dagger/internal/dagger/main/internal/dagger..) and that would be extra work. May try again later.

@grouville

grouville commented Jul 26, 2024 •

Copy link
Copy Markdown
Member

Isolating the root cause

Found the culprit: it is this line -> https://github.com/dagger/dagger/blob/main/sdk/python/dev/dagger.json#L9

As the module's dagger.json has an exclude with **/sdk AND the module lies in this path, it seems to exclude itself. Sounds like a bug, and I am not even sure on why this exclude is necessary.

Found the root cause, working on a fix

@shykes

shykes commented Jul 26, 2024 •

Copy link
Copy Markdown
Contributor Author

As the module's dagger.json has an exclude with **/sdk AND the module lies in this path, it seems to exclude itself. Sounds like a bug, and I am not even sure on why this exclude is necessary.

Thank you @grouville ! This was originally **/dev/sdk, it probably got search-replaced by mistake. I don't understand the original purpose of the exclude. Probably a question for @helderco. Maybe it's a generalization of sdk/python/dev/sdk? ignore what I wrote here, I thought the issue came from the root dagger.json I had edited. I just realized your link was to another dagger.json.

@grouville

grouville commented Jul 26, 2024 •

Copy link
Copy Markdown
Member

As the module's dagger.json has an exclude with **/sdk AND the module lies in this path, it seems to exclude itself. Sounds like a bug, and I am not even sure on why this exclude is necessary.

Thank you @grouville ! This was originally **/dev/sdk, it probably got search-replaced by mistake. I don't understand the original purpose of the exclude. Probably a question for @helderco. Maybe it's a generalization of sdk/python/dev/sdk? ignore what I wrote here, I thought the issue came from the root dagger.json I had edited. I just realized your link was to another dagger.json.

That's the helper: #8045. It does not fix the issue per se, as it is probably a global replace mistake / or a conflict between the exclusion pattern yes, but at least it will add some nice debugging to help the user

@grouville

grouville commented Jul 26, 2024 •

Copy link
Copy Markdown
Member

I just realized your link was to another dagger.json.

I think the issue is a bit more subtle:
When loading a module and its submodules, basically we do not scope the globals to the submodules, parent module's context seems to inherit it (which is understandable with the point of view: an imported module works best when ignoring those files, so parent module should follow the same rules. However, it could lead to below issue):

Example with your PR, with dagger install sdk/python/dev

Includes: [golangci/dagger.json wolfi/dagger.json **/go.work **/*.go graphql/**/* sdk/python/dev/**/* **/go.mod dirdiff/dagger.json dirdiff/**/* wolfi/**/* go/**/* **/go.sum golangci/**/* shellcheck/dagger.json dagger.json **/go.work.sum **/vendor/ .dagger/**/* go/dagger.json graphql/dagger.json shellcheck/**/* sdk/python/dev/dagger.json]"

Excludes: [**/.git **/.direnv **/.venv **/__pycache__ **/.*cache **/sdk]

Here, the **/sdk exclusion interferes with the inclusion sdk/python/dev/**/*, with **/sdk coming from the dagger.json in sdk/python/dev/**/* itself.

3 strategies: find out the conflict and error OR remove one of the two silently (having an opinion in case of conflicts) OR scope exclusions / inclusions globals to the context of their dagger.json ?

I do understand the logic behind inheriting the patterns from the parent module, but this can easily create some funky states

My preference is on erroring, which linked PR does

@shykes

shykes commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

I just realized your link was to another dagger.json.

I think the issue is a bit more subtle: When loading a module and its submodules, basically we do not scope the globals to the submodules, parent module's context seems to inherit it (which is understandable with the point of view: an imported module works best when ignoring those files, so parent module should follow the same rules. However, it could lead to below issue):

Example with your PR, with dagger install sdk/python/dev

Includes: [golangci/dagger.json wolfi/dagger.json **/go.work **/*.go graphql/**/* sdk/python/dev/**/* **/go.mod dirdiff/dagger.json dirdiff/**/* wolfi/**/* go/**/* **/go.sum golangci/**/* shellcheck/dagger.json dagger.json **/go.work.sum **/vendor/ .dagger/**/* go/dagger.json graphql/dagger.json shellcheck/**/* sdk/python/dev/dagger.json]"

Excludes: [**/.git **/.direnv **/.venv **/__pycache__ **/.*cache **/sdk]

Here, the **/sdk exclusion interferes with the inclusion sdk/python/dev/**/*, with **/sdk coming from the dagger.json in sdk/python/dev/**/* itself.

3 strategies: find out the conflict and error OR remove one of the two silently (having an opinion in case of conflicts) OR scope exclusions / inclusions globals to the context of their dagger.json ?

I do understand the logic behind inheriting the patterns from the parent module, but this can easily create some funky states

My preference is on erroring, which linked PR does

I don't think sub-modules should inherit excludes. A module's exclude/include should only apply to itself IMO.

@shykes
shykes force-pushed the dev-dagger-module branch from 5cefc28 to bdd1052 Compare July 26, 2024 09:55
@shykes

shykes commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author
  • Fixed the broken sdk/python/dev import (simply removed the conflicting exclude for now)
  • Updated the README
  • Added a FAQ in the PR description

I would love to get this merged ASAP 🙏

@jedevc

This comment was marked as resolved.

@shykes

This comment was marked as resolved.

@shykes

This comment was marked as resolved.

@helderco

Copy link
Copy Markdown
Contributor

Confusion around python/dev issue

The **/sdk exclude was meant to exclude what's on .gitignore, basically the generated files from the SDK (i.e., sdk/python/dev/sdk), which shouldn't be uploaded back. The starting **/ isn't really needed now, but it was added because the sdk/python/dev module used to have sub-modules.

Additionally, I assumed those exclude patterns were being prefixed with the subdir to the module, relative to the context directory, like include patterns do. Basically I expected it was being expanded to this:
sdk/python/dev/**/sdk, which would exclude any sdk generated dir from those submodules. Haven't confirmed this is not the reality personally, just going off from @grouville's findings.

That pattern can be adjusted, I just want to exclude the sdk inside sdk/python/dev.

Moving /dev to the root changes things because it’s now a parent module to all the monorepo’s modules and that has an impact. @sipsma wrote about this in:

Modules in root

I’m with @jedevc on grouping those modules. Doesn’t have to be in .dagger, which can be reserved for the “dev” module, but at least a github.com/dagger/dagger/modules/shellcheck seems reasonable to me, at least for now. Maybe restructure later with the vanity URLs and bringing them back to .dagger (or keep them in modules, just providing a cooler import URL).

@shykes

This comment was marked as resolved.

@shykes

This comment was marked as resolved.

@helderco

This comment was marked as resolved.

@shykes

This comment was marked as resolved.

@jedevc

This comment was marked as resolved.

@helderco

This comment was marked as resolved.

@shykes

This comment was marked as resolved.

@shykes

This comment was marked as resolved.

@shykes

shykes commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

CI is stuck on this error:

daggerDev.sdk resolve: failed to collect IDs: failed to collect IDs for field "Python": expected *ModuleObject, got <nil>

I was able to reproduce in my local env:

dagger call -m github.com/dagger/dagger@pull/8042/merge --source https://github.com/dagger/dagger#pull/8042/merge sdk python lint

I have to go afk for the rest of the day, if someone can help track this one down in parallel to bikeshedding 🙏

@shykes

shykes commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

References to -m dev in various internal SDK docs

@jedevc I tracked this one down, they're all references to sdk/python/dev and sdk/typescript/dev so orthogonal to this change (although we should get those modules also as a follow-up).

@shykes

shykes commented Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

Relevant: #8048

@matipan

matipan commented Jul 26, 2024 •

Copy link
Copy Markdown
Contributor

I like the idea of having a modules folder where all modules live, even if not all are relevant to the host project. Talking as a newbie to this codebase, I don't think this proposed structure would make understanding how the project is built any harder.

My major concern with using a dot folder is that they are often referred to as hidden folders/files. Going into a terminal and doing an ls on the project would, by default, not show all the dagger specific codebase. Many fuzzy finders also ignore dot folders and files by default (like fzf, ctrl-p and others). Our point with Dagger is that your CI is an important part of your project that you should treat as regular software. Putting the contents of the top level module that builds, packages and releases our software project into a hidden folder makes it feel less relevant. I understand that this approach is already present, such as .github, but I honestly never liked it and I believe dagger code has more importance than the config files often written into . folders.


Edit: I know I'm not suggesting any new alternatives yet. Still trying to think what would be the best approach that we could also recommend to new users.

@wingyplus

Copy link
Copy Markdown
Contributor

Needs to add dev/ps-analyzer module to the module in questions list?

@shykes

shykes commented Aug 7, 2024

Copy link
Copy Markdown
Contributor Author

I'm back online, picking this back up. Any merge conflicts to look out for @jedevc @helderco ? Is this a lost cause?

@shykes
shykes force-pushed the dev-dagger-module branch from 11569cf to 0437104 Compare August 7, 2024 23:23
@shykes
shykes requested a review from a team as a code owner August 7, 2024 23:23
@shykes
shykes force-pushed the dev-dagger-module branch 2 times, most recently from 5170ea6 to 26d204c Compare August 9, 2024 08:50
@shykes

shykes commented Aug 9, 2024

Copy link
Copy Markdown
Contributor Author

@jedevc @helderco @matipan it looks like we have consensus on moving sub-modules to modules/, so I pushed that.

@shykes

shykes commented Aug 9, 2024

Copy link
Copy Markdown
Contributor Author

Needs to add dev/ps-analyzer module to the module in questions list?

Done! Thank you

shykes and others added 3 commits August 9, 2024 11:16
- Main Dagger module is now github.com/dagger/dagger
- Sub-modules moved to the root of the repo
- The rest is in .dagger
- Update module's README (which btw should be merged into CONTRIBUTING)
- Fix hack/dev
- Remove exclude from sdk/python/dev which triggered an engine bug

Co-authored-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
@jedevc
jedevc force-pushed the dev-dagger-module branch 4 times, most recently from ef60844 to eb5210d Compare August 9, 2024 11:14
@jedevc
jedevc requested a review from a team as a code owner August 9, 2024 11:14
@jedevc

jedevc commented Aug 9, 2024

Copy link
Copy Markdown
Contributor

Think CI should be back and healthy again - approving now, if everything looks good, LGTM 🎉

Comment thread sdk/python/README.md Resolved
Comment thread sdk/python/dev/dagger.json Outdated
"**/.*cache",
"sdk"
],
"exclude": ["**/.venv", "**/__pycache__", "**/.*cache"],

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.

It's a shame that the sdk exclude was removed here. There's a bug where include/exclude patterns from dependencies aren't prefixed with the relative paths to them.

@jedevc
jedevc force-pushed the dev-dagger-module branch 2 times, most recently from 2ccab1c to 3d5a82d Compare August 9, 2024 12:45
Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
jedevc merged commit 979cded into dagger:main Aug 9, 2024
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.

6 participants