-
Notifications
You must be signed in to change notification settings - Fork 563
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
docs: Create language-specific pages #7408
Closed
vikram-dagger
wants to merge
17
commits into
dagger:main
from
vikram-dagger:docs-257-lang-specific-pages
Closed
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0c7244b
docs: Create language-specific pages
vikram-dagger fe940ff
Fix sidebar
vikram-dagger 97b662f
Update sidebar
vikram-dagger 63676f2
Update sidebar
vikram-dagger 7eaf571
Fix missing files
vikram-dagger b65bd4d
Add Python lock file section
vikram-dagger 19f9a1e
Add SDK ref links
vikram-dagger 2844355
Reset sidebar
vikram-dagger 4bfc426
Fix links
vikram-dagger a019956
Remove Python lock file section
vikram-dagger e317b74
Fix links
vikram-dagger b66a55d
Fix conflicting URLs
vikram-dagger e2e4295
Add module structure content
vikram-dagger 12fbd72
Fix links
vikram-dagger f9c14c7
Fix link
vikram-dagger 661da2c
Fix titles
vikram-dagger 2e34060
Fix title
vikram-dagger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
slug: /manuals/developer/python | ||
displayed_sidebar: "current" | ||
toc_max_heading_level: 2 | ||
title: "Python Extras" | ||
--- | ||
|
||
# Python Extras | ||
|
||
This page lists features specific to the Python SDK. | ||
|
||
## Name overrides | ||
|
||
Sometimes it's possible to get into a situation where the name you want to use | ||
for the Dagger API is reserved or has a naming conflict within Python. | ||
|
||
To resolve this, the [`@dagger.function`][@function] decorator and the | ||
[`dagger.field`][dag-field] descriptor have a `name` argument to provide | ||
an alternative name for the Dagger API. And for function arguments, | ||
[annotate][Annotated] with an additional [`dagger.Arg`][dag-arg] metadata. | ||
|
||
Here's an example with a renamed object attribute (and constructor argument), | ||
function and function argument: | ||
|
||
```python file=./snippets/python/name-overrides/main.py | ||
``` | ||
|
||
Confirm with `dagger call --help` that the names were overridden: | ||
|
||
``` | ||
FUNCTIONS | ||
def Definition | ||
import Import the specified image | ||
|
||
ARGUMENTS | ||
--def string Definition (default "latest") | ||
``` | ||
|
||
And the same for the function argument, with `dagger call import --help`: | ||
|
||
``` | ||
ARGUMENTS | ||
--from string Image ref (default "alpine") | ||
``` | ||
|
||
[@function]: https://dagger-io.readthedocs.io/en/latest/module.html#dagger.function | ||
[dag-field]: https://dagger-io.readthedocs.io/en/latest/module.html#dagger.field | ||
[dag-arg]: https://dagger-io.readthedocs.io/en/latest/module.html#dagger.Arg | ||
[Annotated]: https://docs.python.org/3/library/typing.html#typing.Annotated | ||
|
||
## Python debug logs | ||
|
||
The Python SDK prints debugging information at various steps of the execution | ||
flow of a module, which can be very useful in understanding what's being | ||
received from and sent to the API. | ||
|
||
This is done using standard Python [logging](https://docs.python.org/3/howto/logging.html), | ||
so it's highly configurable (for example, saving to a file or sending to an | ||
external system like Sentry). But for a simple lowering of the default logging | ||
level to [logging.DEBUG](https://docs.python.org/3/library/logging.html#logging.DEBUG), | ||
there's a convenience function for that: | ||
|
||
```python file=./snippets/python/debugging/main.py | ||
``` | ||
|
||
:::note | ||
With the TUI, you need to use a progress output that doesn't collapse on success | ||
like `--progress=plain` or `--debug`, otherwise it won't show in the terminal. | ||
::: | ||
|
||
Using the command `dagger call --debug echo --msg="hello"`, should print | ||
something like: | ||
|
||
``` | ||
✔ MyModule.echo(msg: "hello"): String! 0.5s | ||
✔ exec /runtime 0.5s | ||
┃ [DEBUG] dagger.client._session: Configuring shared connection to GraphQL server | ||
┃ [DEBUG] dagger.client._session: Establishing client session to GraphQL server | ||
┃ [DEBUG] dagger.mod._module: invoke => {'parent_name': 'MyModule', 'parent_json': '{}', 'name': 'echo', 'input_args': "{'msg': 'hello'}"} | ||
┃ [DEBUG] dagger.mod._module: resolver => MyModule.echo | ||
┃ [DEBUG] dagger.mod._resolver: func => <Signature (msg: str) -> str> | ||
┃ [DEBUG] dagger.mod._resolver: input args => {'msg': 'hello'} | ||
┃ [DEBUG] dagger.mod._resolver: structured args => {'msg': 'hello'} | ||
┃ [DEBUG] dagger.mod._module: result => 'hello' | ||
┃ [DEBUG] dagger.mod._module: output => '"hello"' | ||
┃ [DEBUG] dagger.client._session: Closing client session to GraphQL server | ||
DEBUG: executing query="query{myModule{echo(msg:\"hello\")}}" | ||
``` | ||
|
||
The above gives a lot of useful information: | ||
- The function and parent object that the API wants to execute | ||
- The parent object's state | ||
- The function's signature | ||
- The user inputs before and after deserialization | ||
- The user inputs after being converted to more complex types (structuring) | ||
- The function's result before and after serialization | ||
|
||
Additionally, with `--debug`, the GraphQL query that the Dagger CLI produced is also shown. |
47 changes: 0 additions & 47 deletions
47
docs/current_docs/manuals/developer/python/558732-name-overrides.mdx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
docs/current_docs/manuals/developer/typescript/406314-aliases.mdx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@helderco the output now contains a very large number of spans, and I wasn't able to find anything similar to what is shown here. Please suggest what should be done for this output.