#I need some help creating and testing
1 messages ยท Page 1 of 1 (latest)
Quick ping on this for @digital solar, @vernal ember and @rustic aspen if they can help
FYI @sleek magnet @keen silo I'm waiting on these pending code snippets to close the services guide
I'll have a look tomorrow on that one
Hi guys, can I do anything to help move this forward? I'm trying to complete the doc today as I'd like to perhaps reuse the code samples in a blog post I'm writing to announce the release
Hey vikram ๐
I've checked this file and after the two fixes it should be good to go:
https://github.com/dagger/dagger/pull/5557/files#diff-a881c5862f904ace1862d4d7c8a232c60e48669f12fc343f494b0225577b7a7a
For expose-host-services-to-container Node version:
https://github.com/dagger/dagger/pull/5557/files#diff-3a588c34f395d41e6768337d5fc31d86d1991b7dbef8fcd5270e8640e571decf
I'm getting an error and can't figure out what is happening ๐ค
For start-stop-services Node version:
https://github.com/dagger/dagger/pull/5557/files#diff-203c5927db8a42ae1a6adb1e5e3f5fe933f0cf9e1646051e9d0ae201000b8362
I'm also getting an error with go test ./...
Yup, I saw those errors
I saw a message from Alex to wrap in hack/dev. Did that work?
yes it works
Ok let's ping @keen silo to see if he can help with the other errors?
@digital solar i know you're super busy with zenith and I'm sorry to ping you on this, but do you think you could add the python examples for services v2 in the above PR?
Hey, sorry @keen lotus! I'm over capacity right now as I'm pushing to get some things out, but it's important not to have the services PR blocked on this so I'll make room. There's no python snippet in expose-host-services-to-container and start-stop-services, is there anything in particular you're finding trouble with?
I'm not sure how to write the async/await calls
for starting services and also how to write the portforward
From those go samples it seems straightforward, you just put an await whenever you use ctx and err in Go. Or in the same places you have await in TS.
Same way as you do with other examples, with virtual env activated: ./hack/dev ./bin/dagger run python <path to script>.
thanks, will try and ping you in case of difficulties
@rustic aspen how did you get the services typescript snippets to run? @daring hare was trying one of them and saw this error:
./hack/dev ./bin/dagger run node --loader ts-node/esm docs/current/guides/snippets/use-services/expose-host-services-to-container/index.ts
...
docs/current/guides/snippets/use-services/expose-host-services-to-container/index.ts(1,33): error TS2307: Cannot find module '@dagger.io/dagger' or its corresponding type declarations.
You cannot run it in the docs directory since you do not have the npm package @dagger.io/dagger installed
You need to create a little project with a package.json and @dagger.io/dagger node modules
If you need any help @daring hare Iโm here
I think my problem is installing the version of the sdk from that branch. Same with python. Do we have docs on that?
@rustic aspen got me sorted out, thanks ๐
basically needed to go to sdk/nodejs and run npm run build, and then reference the local path in my package.json
would be great to have that in a README somewhere, I went through that yesterday and ultimately gave up
trying to figure it out for python and then i'm happy to document it all
cc @digital solar
python -m venv .venv
source .venv/bin/activate
pip install sdk/python
./hack/dev ./bin/dagger run python docs/current/guides/snippets/use-services/expose-host-services-to-container/main.py
Just spitting it out, not tested, but that's the idea.
Perfect, thanks!
Of course up until hack/dev that's a one time setup. If you already have the venv with the sdk installed, just need to activate the venv.
Works! I think I was expecting the pip install sdk/python to require extra steps ๐
and @keen silo I think this is a thing TypeError: Host.service() got an unexpected keyword argument 'frontend'
do you need to run ./hack/make sdk:python:generate if you're making sdk changes locally?
That's only if you have changes in the API that haven't been re-generated yet.
I'm confused what's expected for the start/stop snippets (in snippets/start-stop-services). It runs go test ./... but we don't put any go files in the container to test
I'm not entirely sure if that one is supposed to be executable, or just a model of an implementation. @keen silo will know the answer to this
the latter - it would be great to adjust it to a runnable example, but for now it's just a code sample
could help to add a dummy with[Mounted]Directory("/src") or comment to make that clear
Yes to above and I'll add a note box as well in the text to highlight it for this sample
So long as it runs without erroring out, even if there are no tests, it's ok for me to show it in the guide with an explanatory note
@keen lotus any idea what's going on with netlify? https://app.netlify.com/sites/devel-docs-dagger-io/deploys/65303c6fd63826000811ea76
4:14:18 PM: $ spectaql ./docs-graphql/config.yml -t ./static/api/reference
4:14:19 PM: Found example to be rendered for cacheVolume
4:14:19 PM: Rendering successful.
4:14:19 PM: Found example to be rendered for loadCacheVolumeFromID
4:14:19 PM: Error processing the example for loadCacheVolumeFromID. Error: ENOENT: no such file or directory, open "/opt/build/repo/website/docs-graphql/data/examples/queries/loadCacheVolumeFromID/gql.md"
4:14:19 PM: Found example to be rendered for container
[...]
is this still an issue? first time seeing it here, how can i repro?
going to pull again and check. Also working on a PR for the testing setup in CONTRIBUTING.md
for testing TS from the snippets you need a TS config too but that's kind of a problem specific to this PR where we have SDK changes and new doc snippets on the same branch
I think this is a syntax issue in the snippet and not an SDK issue
working on figuring out the correct syntax
but my python brain is very smooth
This specific error won't break anything, there are missing examples for the graphql api which we should add
however the build failure is due to this Error: Docs markdown link couldn"t be resolved: (./757394-use-service-containers.md) in "/opt/build/repo/docs/current/guides/128409-build-test-publish-php.md" for version current
a ha - I think can fix that quickly, good eye
Maybe when you resolved the conflicts @keen silo this change didn't make it through? It's an easy fix though, just modify the link to be ...use-services.md
yeah, that's probably what happened
ok the python thing i'm struggling with in docs/current/guides/snippets/use-services/expose-host-services-to-container/main.py is
client.host().service(frontend=3306, backend=3306)
the args to service should be ports=[PortForward]
so like in JS it's client.host().service([{ frontend: 3306, backend: 3306 }])
I tried client.host().service(ports=[dagger.PortForward(frontend=3306, backend=3306)]) but that's no good
or rather it works but then complains about protocol being null
i failed on finding the correct syntax for this as well... maybe client.host().service([frontend=3306, backend=3306])?
Tried that too along with a lot of variations ๐ญ I think my last one is right but graphql isn't omitting the protocol field
stepping away for dinner now!
@daring hare I saw that the PR was merged, checked the commit log and I think your code snippet changes weren't included? Will you please open a new PR for those?
What's that with the protocol?
Yeah I believe the plan is to have a follow-up PR just for docs since the original PR was getting massive
the PortForward class has 3 fields: frontend, backend, and protocol. Trying to define it like this: client.host().service(ports=[dagger.PortForward(frontend=3306, backend=3306)]) gave me
gql.transport.exceptions.TransportQueryError: {'message': 'Syntax Error GraphQL request (3:41) Unexpected Name "null"\n\n2: host {\n3: service: service(ports: [{protocol: null, frontend: 3306, backe
โ nd: 3306}]) {\n ^\n4: id: id\n', 'locations': [{'line': 3, 'column': 41}]}
...
2: host {
โ 3: service: service(ports: [{protocol: null, frontend: 3306, backend: 3306}])
In the API it's protocol: NetworkProtocol = TCP so it should accept a null. Probably should be protocol: NetworkProtocol! = TCP.
Yeah, I was just confirming that. Was actually looking at https://github.com/dagger/dagger/blob/74e6393e816af380e410f7582e37de5c52ea02e8/core/schema/host.graphqls#L124. Python should generate the default to be TCP, not None. Can you make an issue?
That syntax isn't right, you need to instantiate the input object:
host_srv = client.host().service([dagger.PortForward(backend=3306, frontend=3306)])
yeah, just tried this and it works: client.host().service(ports=[dagger.PortForward(frontend=3306, backend=3306, protocol='TCP')])
By the way, Python could be more lenient on types but early on in the SDK's life people were complaining with errors blowing up very late when serializing for the query, i.e., AST, so I put a strict typecheck in place because of the much more useful error messages.
Definitely helpful for me, and it looks more like Go
Otherwise you could have used a dict: {"frontend": 3306, "backend": 3306}.
Tried that too ๐ That's how it looks in TS
Hm it's failing if I don't set frontend too, which is supposed to be optional and defaulted to the value of backend
Is the query being sent with frontend: null?
yeah
It's what's on the API, so it's a bug in the API?
Oh, I guess not specified != null.
I'm not actually sure where the defaulting is supposed to happen, it's just what the docs say ๐คท
Hmm... will need to look into it.
I'm wondering if it's because it's in a list instead of a direct argument.
Because the check that doesn't send values that match their defaults is in Arg, which is used on the params directly, not fields of inputs.
I mean here: https://github.com/dagger/dagger/blob/74e6393e816af380e410f7582e37de5c52ea02e8/sdk/python/src/dagger/client/gen.py#L3119. It's this Arg that does the check.
You can see the one bellow has a default of "localhost", that's how it compares.
Yeah I did notice that, I was wondering how that worked
I think the PR will just be the code snippets as the guide itself is already merged
@daring hare will you be making any changes to the go code snippets in the guide?
Sorry missed this ping, yes I'm working on a PR now
approved, thanks!
@digital solar can you please do a quick review of the newly-added scripts? There are 6 in all, they are listed at the top of the PR in https://github.com/dagger/dagger/pull/5929#issue-1952871845
I only see changes in two files.
Yup those were the only changes I found. After talking with @keen silo this just makes the snippets work with what's on main so we can publish the guide, it doesn't fix the issues with the sdk
Vikram said it was 6 scripts listed at the top of the PR that's why I asked.
Sent review.
Ah yeah the others didn't need modifications for me
Ah, sorry for not being clear. That PR has only 2 scripts but there are 6 in all to be reviewed, the remainder were in the previous PR which has already been merged.
Let me know if you want direct links to view them in the repo, if that's easier
I pushed to the branch.