status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
โŒ€
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
field, ok, err := obj.FieldByName(ctx, normalizedName) if err != nil { return nil, fmt.Errorf("failed to get field %q: %w", k, err) } if !ok { continue } delete(value, k) value[normalizedName], err = field.modType.ConvertFromSDKResult(ctx, v) if err != nil { return nil, fmt.Errorf("failed to convert field %q: %w", k, err) } } return value, nil default: return nil, fmt.Errorf("unexpected result value type %T for object %q", value, obj.typeDef.AsObject.Name) } } func (obj *UserModObject) ConvertToSDKInput(ctx context.Context, value any) (any, error) { if value == nil { return nil, nil } switch value := value.(type) { case string: return resourceid.DecodeModuleID(value, obj.typeDef.AsObject.Name) case map[string]any:
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
for k, v := range value { normalizedName := gqlFieldName(k) field, ok, err := obj.FieldByName(ctx, normalizedName) if err != nil { return nil, fmt.Errorf("failed to get field %q: %w", k, err) } if !ok { continue } value[field.metadata.Name], err = field.modType.ConvertToSDKInput(ctx, v) if err != nil { return nil, fmt.Errorf("failed to convert field %q: %w", k, err) } } return value, nil default: return nil, fmt.Errorf("unexpected input value type %T for object %q", value, obj.typeDef.AsObject.Name) } } func (obj *UserModObject) SourceMod() Mod { return obj.mod } func (obj *UserModObject) Fields(ctx context.Context) ([]*UserModField, error) { fields, _, err := obj.loadFieldsAndFunctions(ctx) if err != nil { return nil, err } return fields, nil } func (obj *UserModObject) Functions(ctx context.Context) ([]*UserModFunction, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
_, functions, err := obj.loadFieldsAndFunctions(ctx) if err != nil { return nil, err } return functions, nil } func (obj *UserModObject) loadFieldsAndFunctions(ctx context.Context) ( loadedFields []*UserModField, loadedFunctions []*UserModFunction, rerr error, ) { obj.loadLock.Lock() defer obj.loadLock.Unlock() if len(obj.lazyLoadedFields) > 0 || len(obj.lazyLoadedFunctions) > 0 { return obj.lazyLoadedFields, obj.lazyLoadedFunctions, nil } if obj.loadErr != nil { return nil, nil, obj.loadErr } defer func() { obj.lazyLoadedFields = loadedFields obj.lazyLoadedFunctions = loadedFunctions obj.loadErr = rerr }() runtime, err := obj.mod.Runtime(ctx) if err != nil { return nil, nil, fmt.Errorf("failed to get module runtime: %w", err) } for _, fieldTypeDef := range obj.typeDef.AsObject.Fields { modField, err := newModField(ctx, obj, fieldTypeDef) if err != nil { return nil, nil, fmt.Errorf("failed to create field: %w", err)
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
} loadedFields = append(loadedFields, modField) } for _, fn := range obj.typeDef.AsObject.Functions { modFunction, err := newModFunction(ctx, obj.mod, obj, runtime, fn) if err != nil { return nil, nil, fmt.Errorf("failed to create function: %w", err) } loadedFunctions = append(loadedFunctions, modFunction) } return loadedFields, loadedFunctions, nil } func (obj *UserModObject) FieldByName(ctx context.Context, name string) (*UserModField, bool, error) { fields, _, err := obj.loadFieldsAndFunctions(ctx) if err != nil { return nil, false, err } name = gqlFieldName(name) for _, f := range fields { if gqlFieldName(f.metadata.Name) == name { return f, true, nil } } return nil, false, nil } func (obj *UserModObject) FunctionByName(ctx context.Context, name string) (*UserModFunction, bool, error) { _, functions, err := obj.loadFieldsAndFunctions(ctx) if err != nil { return nil, false, err }
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
name = gqlFieldName(name) for _, fn := range functions { if gqlFieldName(fn.metadata.Name) == name { return fn, true, nil } } return nil, false, nil } func (obj *UserModObject) Schema(ctx context.Context) (*ast.SchemaDocument, Resolvers, error) { ctx = bklog.WithLogger(ctx, bklog.G(ctx).WithField("object", obj.typeDef.AsObject.Name)) bklog.G(ctx).Debug("getting object schema") fields, functions, err := obj.loadFieldsAndFunctions(ctx) if err != nil { return nil, nil, err } typeSchemaDoc := &ast.SchemaDocument{} queryResolver := ObjectResolver{} typeSchemaResolvers := Resolvers{ "Query": queryResolver, } objTypeDef := obj.typeDef.AsObject objName := gqlObjectName(objTypeDef.Name) objASTType, err := typeDefToASTType(obj.typeDef, false) if err != nil { return nil, nil, fmt.Errorf("failed to convert object to schema: %w", err) } modType, ok, err := obj.mod.deps.ModTypeFor(ctx, obj.typeDef) if err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
return nil, nil, fmt.Errorf("failed to get mod type for type def: %w", err) } if ok { if sourceMod := modType.SourceMod(); sourceMod != nil && sourceMod.DagDigest() != obj.mod.DagDigest() { if len(objTypeDef.Fields) > 0 || len(objTypeDef.Functions) > 0 { return nil, nil, fmt.Errorf("cannot attach new fields or functions to object %q from outside module", objName) } return nil, nil, nil } } astDef := &ast.Definition{ Name: objName, Description: formatGqlDescription(objTypeDef.Description), Kind: ast.Object, } astIDDef := &ast.Definition{ Name: objName + "ID", Description: formatGqlDescription("%s identifier", objName), Kind: ast.Scalar, } astLoadDef := &ast.FieldDefinition{ Name: fmt.Sprintf("load%sFromID", objName), Description: formatGqlDescription("Loads a %s from an ID", objName), Arguments: ast.ArgumentDefinitionList{ &ast.ArgumentDefinition{ Name: "id", Type: ast.NonNullNamedType(objName+"ID", nil), },
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
}, Type: ast.NonNullNamedType(objName, nil), } newObjResolver := ObjectResolver{} astDef.Fields = append(astDef.Fields, &ast.FieldDefinition{ Name: "id", Description: formatGqlDescription("A unique identifier for a %s", objName), Type: ast.NonNullNamedType(objName+"ID", nil), }) newObjResolver["id"] = func(p graphql.ResolveParams) (any, error) { return resourceid.EncodeModule(objName, p.Source) } for _, field := range fields { fieldDef, resolver, err := field.Schema(ctx) if err != nil { return nil, nil, err } astDef.Fields = append(astDef.Fields, fieldDef) newObjResolver[fieldDef.Name] = resolver } for _, fn := range functions { fieldDef, resolver, err := fn.Schema(ctx) if err != nil { return nil, nil, err } astDef.Fields = append(astDef.Fields, fieldDef) newObjResolver[fieldDef.Name] = resolver } if len(newObjResolver) > 0 { typeSchemaResolvers[objName] = newObjResolver
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
typeSchemaResolvers[objName+"ID"] = stringResolver[string]() queryResolver[fmt.Sprintf("load%sFromID", objName)] = func(p graphql.ResolveParams) (any, error) { return obj.ConvertFromSDKResult(ctx, p.Args["id"]) } } var constructorFieldDef *ast.FieldDefinition var constructorResolver graphql.FieldResolveFn isMainModuleObject := objName == gqlObjectName(obj.mod.metadata.Name) if isMainModuleObject { constructorFieldDef = &ast.FieldDefinition{ Name: gqlFieldName(objName), Description: formatGqlDescription(objTypeDef.Description), Type: objASTType, } if objTypeDef.Constructor != nil { fnTypeDef := objTypeDef.Constructor if fnTypeDef.ReturnType.Kind != core.TypeDefKindObject { return nil, nil, fmt.Errorf("constructor function for object %s must return that object", objTypeDef.OriginalName) } if fnTypeDef.ReturnType.AsObject.OriginalName != objTypeDef.OriginalName { return nil, nil, fmt.Errorf("constructor function for object %s must return that object", objTypeDef.OriginalName) } runtime, err := obj.mod.Runtime(ctx) if err != nil { return nil, nil, fmt.Errorf("failed to get module runtime: %w", err) } fn, err := newModFunction(ctx, obj.mod, obj, runtime, fnTypeDef) if err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
return nil, nil, fmt.Errorf("failed to create function: %w", err) } fieldDef, resolver, err := fn.Schema(ctx) if err != nil { return nil, nil, fmt.Errorf("failed to get schema for constructor function: %w", err) } constructorFieldDef.Arguments = fieldDef.Arguments constructorResolver = resolver } else { constructorResolver = PassthroughResolver } typeSchemaDoc.Extensions = append(typeSchemaDoc.Extensions, &ast.Definition{ Name: "Query", Kind: ast.Object, Fields: ast.FieldList{constructorFieldDef}, }) queryResolver[constructorFieldDef.Name] = constructorResolver } if len(astDef.Fields) > 0 || constructorFieldDef != nil { typeSchemaDoc.Definitions = append(typeSchemaDoc.Definitions, astDef, astIDDef) typeSchemaDoc.Extensions = append(typeSchemaDoc.Extensions, &ast.Definition{ Name: "Query", Kind: ast.Object, Fields: ast.FieldList{astLoadDef}, }) } return typeSchemaDoc, typeSchemaResolvers, nil } type UserModField struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
obj *UserModObject metadata *core.FieldTypeDef modType ModType } func newModField(ctx context.Context, obj *UserModObject, metadata *core.FieldTypeDef) (*UserModField, error) { modType, ok, err := obj.mod.ModTypeFor(ctx, metadata.TypeDef, true) if err != nil { return nil, fmt.Errorf("failed to get mod type for field %q: %w", metadata.Name, err) } if !ok { return nil, fmt.Errorf("failed to get mod type for field %q", metadata.Name) } return &UserModField{ obj: obj, metadata: metadata, modType: modType, }, nil
closed
dagger/dagger
https://github.com/dagger/dagger
6,286
๐Ÿž Zenith: camelCase automagic issues with PythonSDK
### What is the issue? When attempting to run the examples provided in the dagger module's documentation, I encountered two issues that presumably have the same underlying cause regarding the automatic camelCase conversion performed in the Python SDK. ## First issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#chain-modules-together)): ```python """A Dagger module for saying hello world!.""" from dagger import field, function, object_type @object_type class HelloWorld: greeting: str = field(default="Hello") name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_name(self, name: str) -> "HelloWorld": self.name = name return self @function def message(self) -> str: return f"{self.greeting} {self.name}!" ``` And here is an example query for this module: ```graphql { helloWorld { message withName(name: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` The result is as expected ```plain { "helloWorld": { "message": "Hello, World!", "withName": { "withGreeting": { "message": "Bonjour, Monde!" } } } } ``` Now, if I rename `name` to `my_name`: ```python @object_type class HelloWorld: greeting: str = field(default="Hello") my_name: str = field(default="World") @function def with_greeting(self, greeting: str) -> "HelloWorld": self.greeting = greeting return self @function def with_my_name(self, my_name: str) -> "HelloWorld": self.my_name = my_name return self @function def message(self) -> str: return f"{self.greeting} {self.my_name}!" ``` and use the following query: ```graphql { helloWorld { message withMyName(myName: "Monde") { withGreeting(greeting: "Bonjour") { message } } } } ``` I get this result ```plain { "helloWorld": { "message": "Hello, World!", "withMyName": { "withGreeting": { "message": "Bonjour World!" } } } } ``` ## Second issue Take the following example (taken from [here](https://docs.dagger.io/zenith/developer/python/539756/advanced-programming#write-an-asynchronous-module-constructor-function)): ```python """A Dagger module for searching an input file.""" import dagger from dagger import dag, object_type, field, function @object_type class Grep: src: dagger.File = field() @classmethod async def create(cls, src: dagger.File | None = None): if src is None: src = await dag.http("https://dagger.io") return cls(src=src) @function async def grep(self, pattern: str) -> str: return await ( dag .container() .from_("alpine:latest") .with_mounted_file("/src", self.src) .with_exec(["grep", pattern, "/src"]) .stdout() ) ``` Similarly, if I alter this example by renaming `src` to `my_src`: ```python ... @object_type class Grep: my_src: dagger.File = field() @classmethod async def create(cls, my_src: dagger.File | None = None): if my_src is None: my_src = await dag.http("https://dagger.io") return cls(my_src=my_src) ... ``` I get the following error: ```shell $ dagger call grep --pattern dagger โœ˜ dagger call grep ERROR [1.92s] โ”ƒ Error: response from query: input:1: grep.grep failed to get function output directory: process "/runtime" did not complete successfully: exit code: 1 โœ˜ grep(pattern: "dagger") ERROR [0.85s] โœ˜ exec /runtime ERROR [0.85s] โ”ƒ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Traceback (most recent call last) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”ƒ โ”‚ /runtime:8 in <module> โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 5 from dagger.mod.cli import app โ”‚ โ”ƒ โ”‚ 6 โ”‚ โ”ƒ โ”‚ 7 if __name__ == "__main__": โ”‚ โ”ƒ โ”‚ โฑ 8 โ”‚ sys.exit(app()) โ”‚ โ”ƒ โ”‚ 9 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/cli.py:32 in app โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 29 โ”‚ ) โ”‚ โ”ƒ โ”‚ 30 โ”‚ try: โ”‚ โ”ƒ โ”‚ 31 โ”‚ โ”‚ mod = get_module() โ”‚ โ”ƒ โ”‚ โฑ 32 โ”‚ โ”‚ mod() โ”‚ โ”ƒ โ”‚ 33 โ”‚ except FatalError as e: โ”‚ โ”ƒ โ”‚ 34 โ”‚ โ”‚ if logger.isEnabledFor(logging.DEBUG): โ”‚ โ”ƒ โ”‚ 35 โ”‚ โ”‚ โ”‚ logger.exception("Fatal error") โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:181 in __call__ โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 178 โ”‚ def __call__(self) -> None: โ”‚ โ”ƒ โ”‚ 179 โ”‚ โ”‚ if self._log_level is not None: โ”‚ โ”ƒ โ”‚ 180 โ”‚ โ”‚ โ”‚ configure_logging(self._log_level) โ”‚ โ”ƒ โ”‚ โฑ 181 โ”‚ โ”‚ anyio.run(self._run) โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_core/_eventloop.py:66 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 63 โ”‚ โ”‚ โ”ƒ โ”‚ 64 โ”‚ try: โ”‚ โ”ƒ โ”‚ 65 โ”‚ โ”‚ backend_options = backend_options or {} โ”‚ โ”ƒ โ”‚ โฑ 66 โ”‚ โ”‚ return async_backend.run(func, args, {}, backend_options) โ”‚ โ”ƒ โ”‚ 67 โ”‚ finally: โ”‚ โ”ƒ โ”‚ 68 โ”‚ โ”‚ if token: โ”‚ โ”ƒ โ”‚ 69 โ”‚ โ”‚ โ”‚ sniffio.current_async_library_cvar.reset(token) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1960 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1957 โ”‚ โ”‚ debug = options.get("debug", False) โ”‚ โ”ƒ โ”‚ 1958 โ”‚ โ”‚ options.get("loop_factory", None) โ”‚ โ”ƒ โ”‚ 1959 โ”‚ โ”‚ options.get("use_uvloop", False) โ”‚ โ”ƒ โ”‚ โฑ 1960 โ”‚ โ”‚ return native_run(wrapper(), debug=debug) โ”‚ โ”ƒ โ”‚ 1961 โ”‚ โ”‚ โ”ƒ โ”‚ 1962 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 1963 โ”‚ def current_token(cls) -> object: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:190 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ โ”‚ โ”‚ "asyncio.run() cannot be called from a running event loop" โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ โ”ƒ โ”‚ 189 โ”‚ with Runner(debug=debug) as runner: โ”‚ โ”ƒ โ”‚ โฑ 190 โ”‚ โ”‚ return runner.run(main) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”ƒ โ”‚ 193 def _cancel_all_tasks(loop): โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/runners.py:118 in run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 115 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 116 โ”‚ โ”‚ self._interrupt_count = 0 โ”‚ โ”ƒ โ”‚ 117 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 118 โ”‚ โ”‚ โ”‚ return self._loop.run_until_complete(task) โ”‚ โ”ƒ โ”‚ 119 โ”‚ โ”‚ except exceptions.CancelledError: โ”‚ โ”ƒ โ”‚ 120 โ”‚ โ”‚ โ”‚ if self._interrupt_count > 0: โ”‚ โ”ƒ โ”‚ 121 โ”‚ โ”‚ โ”‚ โ”‚ uncancel = getattr(task, "uncancel", None) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/asyncio/base_events.py:653 in run_until_complete โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 650 โ”‚ โ”‚ if not future.done(): โ”‚ โ”ƒ โ”‚ 651 โ”‚ โ”‚ โ”‚ raise RuntimeError('Event loop stopped before Future comp โ”‚ โ”ƒ โ”‚ 652 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 653 โ”‚ โ”‚ return future.result() โ”‚ โ”ƒ โ”‚ 654 โ”‚ โ”‚ โ”ƒ โ”‚ 655 โ”‚ def stop(self): โ”‚ โ”ƒ โ”‚ 656 โ”‚ โ”‚ """Stop running the event loop. โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:1953 in โ”‚ โ”ƒ โ”‚ wrapper โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 1950 โ”‚ โ”‚ โ”‚ _task_states[task] = TaskState(None, None) โ”‚ โ”ƒ โ”‚ 1951 โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 1952 โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 1953 โ”‚ โ”‚ โ”‚ โ”‚ return await func(*args) โ”‚ โ”ƒ โ”‚ 1954 โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ 1955 โ”‚ โ”‚ โ”‚ โ”‚ del _task_states[task] โ”‚ โ”ƒ โ”‚ 1956 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:185 in _run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 182 โ”‚ โ”‚ โ”ƒ โ”‚ 183 โ”‚ async def _run(self): โ”‚ โ”ƒ โ”‚ 184 โ”‚ โ”‚ async with await dagger.connect(): โ”‚ โ”ƒ โ”‚ โฑ 185 โ”‚ โ”‚ โ”‚ await self._serve() โ”‚ โ”ƒ โ”‚ 186 โ”‚ โ”‚ โ”ƒ โ”‚ 187 โ”‚ async def _serve(self): โ”‚ โ”ƒ โ”‚ 188 โ”‚ โ”‚ mod_name = await self._mod.name() โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:193 in _serve โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 190 โ”‚ โ”‚ resolvers = self.get_resolvers(mod_name) โ”‚ โ”ƒ โ”‚ 191 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 192 โ”‚ โ”‚ result = ( โ”‚ โ”ƒ โ”‚ โฑ 193 โ”‚ โ”‚ โ”‚ await self._invoke(resolvers, parent_name) โ”‚ โ”ƒ โ”‚ 194 โ”‚ โ”‚ โ”‚ if parent_name โ”‚ โ”ƒ โ”‚ 195 โ”‚ โ”‚ โ”‚ else await self._register(resolvers, to_pascal_case(mod_na โ”‚ โ”ƒ โ”‚ 196 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:266 in _invoke โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 263 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 264 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 265 โ”‚ โ”‚ resolver = self.get_resolver(resolvers, parent_name, name) โ”‚ โ”ƒ โ”‚ โฑ 266 โ”‚ โ”‚ return await self.get_result(resolver, parent_json, inputs) โ”‚ โ”ƒ โ”‚ 267 โ”‚ โ”‚ โ”ƒ โ”‚ 268 โ”‚ async def get_result( โ”‚ โ”ƒ โ”‚ 269 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:279 in get_result โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 276 โ”‚ โ”‚ โ”‚ isinstance(resolver, FunctionResolver) โ”‚ โ”ƒ โ”‚ 277 โ”‚ โ”‚ โ”‚ and inspect.isclass(resolver.wrapped_func) โ”‚ โ”ƒ โ”‚ 278 โ”‚ โ”‚ ): โ”‚ โ”ƒ โ”‚ โฑ 279 โ”‚ โ”‚ โ”‚ root = await self.get_root(resolver.origin, parent_json) โ”‚ โ”ƒ โ”‚ 280 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 281 โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ 282 โ”‚ โ”‚ โ”‚ result = await resolver.get_result(self._converter, root, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /sdk/src/dagger/mod/_module.py:325 in get_root โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 322 โ”‚ โ”‚ if not parent: โ”‚ โ”ƒ โ”‚ 323 โ”‚ โ”‚ โ”‚ return origin() โ”‚ โ”ƒ โ”‚ 324 โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 325 โ”‚ โ”‚ return await asyncify(self._converter.structure, parent, origi โ”‚ โ”ƒ โ”‚ 326 โ”‚ โ”‚ โ”ƒ โ”‚ 327 โ”‚ def field( โ”‚ โ”ƒ โ”‚ 328 โ”‚ โ”‚ self, โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/to_thread.py:49 in run_sync โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 46 โ”‚ โ”‚ โ”‚ stacklevel=2, โ”‚ โ”ƒ โ”‚ 47 โ”‚ โ”‚ ) โ”‚ โ”ƒ โ”‚ 48 โ”‚ โ”‚ โ”ƒ โ”‚ โฑ 49 โ”‚ return await get_async_backend().run_sync_in_worker_thread( โ”‚ โ”ƒ โ”‚ 50 โ”‚ โ”‚ func, args, abandon_on_cancel=abandon_on_cancel, limiter=limite โ”‚ โ”ƒ โ”‚ 51 โ”‚ ) โ”‚ โ”ƒ โ”‚ 52 โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:2103 in โ”‚ โ”ƒ โ”‚ run_sync_in_worker_thread โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 2100 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ worker_scope = scope._parent_scope โ”‚ โ”ƒ โ”‚ 2101 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”ƒ โ”‚ 2102 โ”‚ โ”‚ โ”‚ โ”‚ worker.queue.put_nowait((context, func, args, future, โ”‚ โ”ƒ โ”‚ โฑ 2103 โ”‚ โ”‚ โ”‚ โ”‚ return await future โ”‚ โ”ƒ โ”‚ 2104 โ”‚ โ”‚ โ”ƒ โ”‚ 2105 โ”‚ @classmethod โ”‚ โ”ƒ โ”‚ 2106 โ”‚ def check_cancelled(cls) -> None: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:823 in โ”‚ โ”ƒ โ”‚ run โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 820 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception: BaseException | None = None โ”‚ โ”ƒ โ”‚ 821 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ threadlocals.current_cancel_scope = cancel_scope โ”‚ โ”ƒ โ”‚ 822 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ try: โ”‚ โ”ƒ โ”‚ โฑ 823 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ result = context.run(func, *args) โ”‚ โ”ƒ โ”‚ 824 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ except BaseException as exc: โ”‚ โ”ƒ โ”‚ 825 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ exception = exc โ”‚ โ”ƒ โ”‚ 826 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ finally: โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ /usr/local/lib/python3.11/site-packages/cattrs/converters.py:332 in โ”‚ โ”ƒ โ”‚ structure โ”‚ โ”ƒ โ”‚ โ”‚ โ”ƒ โ”‚ 329 โ”‚ โ”‚ โ”ƒ โ”‚ 330 โ”‚ def structure(self, obj: Any, cl: Type[T]) -> T: โ”‚ โ”ƒ โ”‚ 331 โ”‚ โ”‚ """Convert unstructured Python data structures to structured โ”‚ โ”ƒ โ”‚ โฑ 332 โ”‚ โ”‚ return self._structure_func.dispatch(cl)(obj, cl) โ”‚ โ”ƒ โ”‚ 333 โ”‚ โ”‚ โ”ƒ โ”‚ 334 โ”‚ # Classes to Python primitives. โ”‚ โ”ƒ โ”‚ 335 โ”‚ def unstructure_attrs_asdict(self, obj: Any) -> Dict[str, Any]: โ”‚ โ”ƒ โ”‚ in structure_Grep:9 โ”‚ โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”ƒ ClassValidationError: While structuring Grep (1 sub-exception) โ€ข Engine: 9e91eb66912d (version v0.9.4) โง— 20.86s โœ” 112 โˆ… 16 โœ˜ 3 ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce _No response_ ### Log output _No response_
https://github.com/dagger/dagger/issues/6286
https://github.com/dagger/dagger/pull/6287
1502402c4c028f15165a14ea8f05260057c8141e
62e02912129760bc86c309e5107dd7eb463ac2bf
2023-12-16T16:19:10Z
go
2023-12-20T11:15:41Z
core/schema/usermod.go
} func (f *UserModField) Schema(ctx context.Context) (*ast.FieldDefinition, graphql.FieldResolveFn, error) { typeDef := f.metadata.TypeDef fieldASTType, err := typeDefToASTType(typeDef, false) if err != nil { return nil, nil, err } sourceMod := f.modType.SourceMod() if sourceMod != nil && sourceMod.Name() != coreModuleName && sourceMod.DagDigest() != f.obj.mod.DagDigest() { return nil, nil, fmt.Errorf("object %q field %q cannot reference external type from dependency module %q", f.obj.typeDef.AsObject.OriginalName, f.metadata.OriginalName, sourceMod.Name(), ) } fieldDef := &ast.FieldDefinition{ Name: f.metadata.Name, Description: formatGqlDescription(f.metadata.Description), Type: fieldASTType, } return fieldDef, func(p graphql.ResolveParams) (any, error) { res, err := graphql.DefaultResolveFn(p) if err != nil { return nil, err } return f.modType.ConvertFromSDKResult(ctx, res) }, nil }
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
package main import ( "bufio" "context" "encoding/json" "errors" "fmt" "io" "net" "net/http" "os" "os/exec" "os/signal" "path/filepath" "runtime" "runtime/debug" "strconv" "strings" "sync" "syscall" "time" "github.com/cenkalti/backoff/v4" "github.com/dagger/dagger/core" "github.com/dagger/dagger/engine/buildkit"
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
"github.com/dagger/dagger/engine/client" "github.com/dagger/dagger/network" "github.com/google/uuid" "github.com/opencontainers/go-digest" "github.com/opencontainers/runtime-spec/specs-go" "github.com/vito/progrock" "golang.org/x/sys/unix" ) const ( metaMountPath = "/.dagger_meta_mount" stdinPath = metaMountPath + "/stdin" exitCodePath = metaMountPath + "/exitCode" runcPath = "/usr/local/bin/runc" shimPath = "/_shim" errorExitCode = 125 ) var ( stdoutPath = metaMountPath + "/stdout" stderrPath = metaMountPath + "/stderr" pipeWg sync.WaitGroup ) /* There are two "subcommands" of this binary: 1. The setupBundle command, which is invoked by buildkitd as the oci executor. It updates the spec provided by buildkitd's executor to wrap the command in our shim (described below). It then exec's to runc which will do the actual container setup+execution. 2. The shim, which is included in each Container.Exec and enables us to capture/redirect stdio, capture the exit code, etc. */ func main() {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
defer func() { if err := recover(); err != nil { fmt.Fprintf(os.Stderr, "panic: %v %s\n", err, string(debug.Stack())) os.Exit(errorExitCode) } }() if os.Args[0] == shimPath { if _, found := internalEnv("_DAGGER_INTERNAL_COMMAND"); found { os.Exit(internalCommand()) return } os.Exit(shim()) } else { os.Exit(setupBundle()) } } func internalCommand() int {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "usage: %s <command> [<args>]\n", os.Args[0]) return errorExitCode } cmd := os.Args[1] args := os.Args[2:] switch cmd { case "check": if err := check(args); err != nil { fmt.Fprintln(os.Stderr, err) return errorExitCode } return 0 case "tunnel": if err := tunnel(args); err != nil { fmt.Fprintln(os.Stderr, err) return 1 } return 0 default: fmt.Fprintf(os.Stderr, "unknown command: %s\n", cmd) return errorExitCode } } func check(args []string) error {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
if len(args) == 0 { return fmt.Errorf("usage: check <host> port/tcp [port/udp ...]") } host, ports := args[0], args[1:] for _, port := range ports { port, network, ok := strings.Cut(port, "/") if !ok { network = "tcp" } pollAddr := net.JoinHostPort(host, port) fmt.Println("polling for port", pollAddr) reached, err := pollForPort(network, pollAddr) if err != nil { return fmt.Errorf("poll %s: %w", pollAddr, err) } fmt.Println("port is up at", reached) } return nil } func pollForPort(network, addr string) (string, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
retry := backoff.NewExponentialBackOff() retry.InitialInterval = 100 * time.Millisecond dialer := net.Dialer{ Timeout: time.Second, } var reached string err := backoff.Retry(func() error { conn, err := dialer.Dial(network, addr) if err != nil { fmt.Fprintf(os.Stderr, "port not ready: %s; elapsed: %s\n", err, retry.GetElapsedTime()) return err } reached = conn.RemoteAddr().String() _ = conn.Close() return nil }, retry) if err != nil { return "", err } return reached, nil } func shim() (returnExitCode int) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
ctx, cancel := context.WithCancel(context.Background()) defer cancel() if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "usage: %s <path> [<args>]\n", os.Args[0]) return errorExitCode } name := os.Args[1] args := []string{} if len(os.Args) > 2 { args = os.Args[2:] } cmd := exec.Command(name, args...) _, isTTY := internalEnv(core.ShimEnableTTYEnvVar) if isTTY { cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr } else { if stdinFile, err := os.Open(stdinPath); err == nil { defer stdinFile.Close() cmd.Stdin = stdinFile } else { cmd.Stdin = nil } var secretsToScrub core.SecretToScrubInfo secretsToScrubVar, found := internalEnv("_DAGGER_SCRUB_SECRETS")
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
if found { err := json.Unmarshal([]byte(secretsToScrubVar), &secretsToScrub) if err != nil { panic(fmt.Errorf("cannot load secrets to scrub: %w", err)) } } currentDirPath := "/" shimFS := os.DirFS(currentDirPath) stdoutFile, err := os.Create(stdoutPath) if err != nil { panic(err) } defer stdoutFile.Close() stdoutRedirect := io.Discard stdoutRedirectPath, found := internalEnv("_DAGGER_REDIRECT_STDOUT") if found { stdoutRedirectFile, err := os.Create(stdoutRedirectPath) if err != nil { panic(err) } defer stdoutRedirectFile.Close() stdoutRedirect = stdoutRedirectFile } stderrFile, err := os.Create(stderrPath) if err != nil { panic(err) } defer stderrFile.Close() stderrRedirect := io.Discard stderrRedirectPath, found := internalEnv("_DAGGER_REDIRECT_STDERR")
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
if found { stderrRedirectFile, err := os.Create(stderrRedirectPath) if err != nil { panic(err) } defer stderrRedirectFile.Close() stderrRedirect = stderrRedirectFile } outWriter := io.MultiWriter(stdoutFile, stdoutRedirect, os.Stdout) errWriter := io.MultiWriter(stderrFile, stderrRedirect, os.Stderr) if len(secretsToScrub.Envs) == 0 && len(secretsToScrub.Files) == 0 { cmd.Stdout = outWriter cmd.Stderr = errWriter } else { envToScrub := os.Environ() stdoutPipe, err := cmd.StdoutPipe() if err != nil { panic(err) } scrubOutReader, err := NewSecretScrubReader(stdoutPipe, currentDirPath, shimFS, envToScrub, secretsToScrub) if err != nil { panic(err) } pipeWg.Add(1) go func() { defer pipeWg.Done() io.Copy(outWriter, scrubOutReader) }()
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
stderrPipe, err := cmd.StderrPipe() if err != nil { panic(err) } scrubErrReader, err := NewSecretScrubReader(stderrPipe, currentDirPath, shimFS, envToScrub, secretsToScrub) if err != nil { panic(err) } pipeWg.Add(1) go func() { defer pipeWg.Done() io.Copy(errWriter, scrubErrReader) }() } } exitCode := 0 if err := runWithNesting(ctx, cmd); err != nil { exitCode = errorExitCode if exiterr, ok := err.(*exec.ExitError); ok { exitCode = exiterr.ExitCode() } else { panic(err) } } if err := os.WriteFile(exitCodePath, []byte(fmt.Sprintf("%d", exitCode)), 0o600); err != nil { panic(err) } return exitCode } func setupBundle() int {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
var bundleDir string var isRun bool for i, arg := range os.Args { if arg == "--bundle" && i+1 < len(os.Args) { bundleDir = os.Args[i+1] } if arg == "run" { isRun = true } } if bundleDir == "" || !isRun { return execRunc() } configPath := filepath.Join(bundleDir, "config.json") configBytes, err := os.ReadFile(configPath) if err != nil { fmt.Printf("Error reading config.json: %v\n", err) return errorExitCode } var spec specs.Spec if err := json.Unmarshal(configBytes, &spec); err != nil { fmt.Printf("Error parsing config.json: %v\n", err) return errorExitCode
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
} var isDaggerExec bool for _, mnt := range spec.Mounts { if mnt.Destination == metaMountPath { isDaggerExec = true break } } for _, env := range spec.Process.Env { if strings.HasPrefix(env, "_DAGGER_INTERNAL_COMMAND=") { isDaggerExec = true break } } if isDaggerExec { selfPath, err := os.Executable() if err != nil { fmt.Printf("Error getting self path: %v\n", err) return errorExitCode } selfPath, err = filepath.EvalSymlinks(selfPath) if err != nil { fmt.Printf("Error getting self path: %v\n", err) return errorExitCode
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
} spec.Mounts = append(spec.Mounts, specs.Mount{ Destination: shimPath, Type: "bind", Source: selfPath, Options: []string{"rbind", "ro"}, }) spec.Hooks = &specs.Hooks{} if gpuSupportEnabled := os.Getenv("_EXPERIMENTAL_DAGGER_GPU_SUPPORT"); gpuSupportEnabled != "" { spec.Hooks.Prestart = []specs.Hook{ { Args: []string{ "nvidia-container-runtime-hook", "prestart", }, Path: "/usr/bin/nvidia-container-runtime-hook", }, } } spec.Process.Args = append([]string{shimPath}, spec.Process.Args...) } execMetadata := new(buildkit.ContainerExecUncachedMetadata) for i, env := range spec.Process.Env { found, err := execMetadata.FromEnv(env) if err != nil { fmt.Printf("Error parsing env: %v\n", err) return errorExitCode } if found {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
spec.Process.Env = append(spec.Process.Env[:i], spec.Process.Env[i+1:]...) break } } var searchDomains []string for _, parentClientID := range execMetadata.ParentClientIDs { searchDomains = append(searchDomains, network.ClientDomain(parentClientID)) } if len(searchDomains) > 0 { spec.Process.Env = append(spec.Process.Env, "_DAGGER_PARENT_CLIENT_IDS="+strings.Join(execMetadata.ParentClientIDs, " ")) } var hostsFilePath string for i, mnt := range spec.Mounts { switch mnt.Destination { case "/etc/hosts": hostsFilePath = mnt.Source case "/etc/resolv.conf": if len(searchDomains) == 0 { break } newResolvPath := filepath.Join(bundleDir, "resolv.conf") newResolv, err := os.Create(newResolvPath) if err != nil { panic(err) } if err := replaceSearch(newResolv, mnt.Source, searchDomains); err != nil { panic(err) } if err := newResolv.Close(); err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
panic(err) } spec.Mounts[i].Source = newResolvPath } } var gpuParams string keepEnv := []string{} for _, env := range spec.Process.Env { switch { case strings.HasPrefix(env, "_DAGGER_ENABLE_NESTING="): keepEnv = append(keepEnv, env) if execMetadata.ServerID == "" { fmt.Fprintln(os.Stderr, "missing server id") return errorExitCode } keepEnv = append(keepEnv, "_DAGGER_SERVER_ID="+execMetadata.ServerID) spec.Mounts = append(spec.Mounts, specs.Mount{ Destination: "/.runner.sock", Type: "bind", Options: []string{"rbind"}, Source: "/run/buildkit/buildkitd.sock", }) spec.Mounts = append(spec.Mounts, specs.Mount{ Destination: "/bin/dagger", Type: "bind", Options: []string{"rbind", "ro"},
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
Source: "/usr/local/bin/dagger", }) if execMetadata.ProgSockPath == "" { fmt.Fprintln(os.Stderr, "missing progsock path") return errorExitCode } spec.Mounts = append(spec.Mounts, specs.Mount{ Destination: "/.progrock.sock", Type: "bind", Options: []string{"rbind"}, Source: execMetadata.ProgSockPath, }) case strings.HasPrefix(env, "_DAGGER_SERVER_ID="): case strings.HasPrefix(env, aliasPrefix): if err := appendHostAlias(hostsFilePath, env, searchDomains); err != nil { fmt.Fprintln(os.Stderr, "host alias:", err) return errorExitCode } case strings.HasPrefix(env, "_EXPERIMENTAL_DAGGER_GPU_PARAMS"): splits := strings.Split(env, "=") gpuParams = splits[1] default: keepEnv = append(keepEnv, env) } } spec.Process.Env = keepEnv if gpuParams != "" {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
spec.Process.Env = append(spec.Process.Env, fmt.Sprintf("NVIDIA_VISIBLE_DEVICES=%s", gpuParams)) } configBytes, err = json.Marshal(spec) if err != nil { fmt.Printf("Error marshaling config.json: %v\n", err) return errorExitCode } if err := os.WriteFile(configPath, configBytes, 0o600); err != nil { fmt.Printf("Error writing config.json: %v\n", err) return errorExitCode } exitCodeCh := make(chan int) go func() { runtime.LockOSThread() defer runtime.UnlockOSThread() defer close(exitCodeCh) cmd := exec.Command(runcPath, os.Args[1:]...) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.SysProcAttr = &syscall.SysProcAttr{ Pdeathsig: syscall.SIGKILL, } sigCh := make(chan os.Signal, 32) signal.Notify(sigCh)
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
if err := cmd.Start(); err != nil { fmt.Printf("Error starting runc: %v", err) exitCodeCh <- errorExitCode return } go func() { for sig := range sigCh { cmd.Process.Signal(sig) } }() if err := cmd.Wait(); err != nil { if exiterr, ok := err.(*exec.ExitError); ok { if waitStatus, ok := exiterr.Sys().(syscall.WaitStatus); ok { exitcode := waitStatus.ExitStatus() if exitcode < 0 { exitcode = errorExitCode } exitCodeCh <- exitcode return } } fmt.Printf("Error waiting for runc: %v", err) exitCodeCh <- errorExitCode return } }() return <-exitCodeCh } const aliasPrefix = "_DAGGER_HOSTNAME_ALIAS_" func appendHostAlias(hostsFilePath string, env string, searchDomains []string) error {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
alias, target, ok := strings.Cut(strings.TrimPrefix(env, aliasPrefix), "=") if !ok { return fmt.Errorf("malformed host alias: %s", env) } var ips []net.IP var errs error for _, domain := range append([]string{""}, searchDomains...) { qualified := target if domain != "" { qualified += "." + domain } var err error ips, err = net.LookupIP(qualified) if err == nil { errs = nil break } errs = errors.Join(errs, err) } if errs != nil { return errs
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
} hostsFile, err := os.OpenFile(hostsFilePath, os.O_APPEND|os.O_WRONLY, 0o777) if err != nil { return err } for _, ip := range ips { if _, err := fmt.Fprintf(hostsFile, "\n%s\t%s\n", ip, alias); err != nil { return err } } return hostsFile.Close() } func execRunc() int { args := []string{runcPath} args = append(args, os.Args[1:]...) if err := unix.Exec(runcPath, args, os.Environ()); err != nil { fmt.Printf("Error execing runc: %v\n", err) return errorExitCode } panic("congratulations: you've reached unreachable code, please report a bug!") } func internalEnv(name string) (string, bool) { val, found := os.LookupEnv(name) if !found { return "", false } os.Unsetenv(name) return val, true } func runWithNesting(ctx context.Context, cmd *exec.Cmd) error {
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
if _, found := internalEnv("_DAGGER_ENABLE_NESTING"); !found { if err := cmd.Start(); err != nil { return err } pipeWg.Wait() if err := cmd.Wait(); err != nil { return err } return nil } sessionToken, engineErr := uuid.NewRandom() if engineErr != nil { return fmt.Errorf("error generating session token: %w", engineErr) } l, engineErr := net.Listen("tcp", "127.0.0.1:0") if engineErr != nil { return fmt.Errorf("error listening on session socket: %w", engineErr) } sessionPort := l.Addr().(*net.TCPAddr).Port parentClientIDsVal, _ := internalEnv("_DAGGER_PARENT_CLIENT_IDS") clientParams := client.Params{ SecretToken: sessionToken.String(), RunnerHost: "unix:///.runner.sock", ParentClientIDs: strings.Fields(parentClientIDsVal), } if _, ok := internalEnv("_DAGGER_ENABLE_NESTING_IN_SAME_SESSION"); ok { serverID, ok := internalEnv("_DAGGER_SERVER_ID")
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
if !ok { return fmt.Errorf("missing _DAGGER_SERVER_ID") } clientParams.ServerID = serverID } moduleCallerDigest, ok := internalEnv("_DAGGER_MODULE_CALLER_DIGEST") if ok { clientParams.ModuleCallerDigest = digest.Digest(moduleCallerDigest) } progW, err := progrock.DialRPC(ctx, "unix:///.progrock.sock") if err != nil { return fmt.Errorf("error connecting to progrock: %w", err) } clientParams.ProgrockWriter = progW sess, ctx, err := client.Connect(ctx, clientParams) if err != nil { return fmt.Errorf("error connecting to engine: %w", err) } defer sess.Close() _ = ctx go http.Serve(l, sess) os.Setenv("DAGGER_SESSION_PORT", strconv.Itoa(sessionPort)) os.Setenv("DAGGER_SESSION_TOKEN", sessionToken.String()) err = cmd.Start() if err != nil { return err } pipeWg.Wait() err = cmd.Wait()
closed
dagger/dagger
https://github.com/dagger/dagger
6,266
๐Ÿž shim: panic when exec-ing an unknown command
### What is the issue? Noticed during #6117 that some integration tests were causing a panic to show in the TUI. @sipsma reported in https://github.com/dagger/dagger/pull/6117#pullrequestreview-1778643232. The tests pass fine and the SDK gets a correct `dagger.ExecError`, but the panic pollutes the screen and makes it seem like there's a bigger problem. The issue is in the shim: https://github.com/dagger/dagger/blob/970bcfe512cfc699005c46992f52a8f1d17c2af3/cmd/shim/main.go#L285-L293 Where `runWithNesting` isn't returning an expected `exiterr.ExitError`. Instead of panicking should try set the right exit code (from `runWithNesting`) or default to `exitCode = -1`. ### Log output ```shell โฏ dagger run --focus go run main.go โœ˜ sync ERROR [0.54s] โœ˜ exec foobar ERROR [0.12s] โ”ƒ panic: exec: "foobar": executable file not found in $PATH goroutine 1 [running, locked to โ”ƒ read]: โ”ƒ runtime/debug.Stack() โ”ƒ /usr/local/go/src/runtime/debug/stack.go:24 +0x64 โ”ƒ main.main.func1() โ”ƒ /app/cmd/shim/main.go:63 +0x34 โ”ƒ panic({0xa7d960?, 0x4000528b00?}) โ”ƒ /usr/local/go/src/runtime/panic.go:914 +0x218 โ”ƒ main.shim() โ”ƒ /app/cmd/shim/main.go:291 +0xda8 โ”ƒ main.main() โ”ƒ /app/cmd/shim/main.go:76 +0x98 โ€ข Engine: f4abd4cd1f6c (version v0.9.4) โง— 14.47s โœ” 12 โœ˜ 2 ``` ### Steps to reproduce Just try exec-ing a non-existing command or getting a directory that doesn't exist: ```go package main import ( "context" "fmt" "log" "dagger.io/dagger" ) func main() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { log.Println(err) return } defer client.Close() _, err = client.Container().From("alpine").WithExec([]string{"foobar"}).Sync(ctx) if err != nil { log.Println(err) return } fmt.Println("Done!") } ``` ### Dagger version dagger v0.9.4 (registry.dagger.io/engine) darwin/arm64
https://github.com/dagger/dagger/issues/6266
https://github.com/dagger/dagger/pull/6356
7a13be4bb56171c7d841fc603bbcea34ee8b50b5
25e858ba1900134a7f3d84de66286f29680273c5
2023-12-13T13:05:51Z
go
2024-01-04T13:07:53Z
cmd/shim/main.go
if err != nil { return err } return nil } func replaceSearch(dst io.Writer, resolv string, searchDomains []string) error { src, err := os.Open(resolv) if err != nil { return nil } defer src.Close() srcScan := bufio.NewScanner(src) var replaced bool for srcScan.Scan() { if !strings.HasPrefix(srcScan.Text(), "search") { fmt.Fprintln(dst, srcScan.Text()) continue } oldDomains := strings.Fields(srcScan.Text())[1:] newDomains := append([]string{}, searchDomains...) newDomains = append(newDomains, oldDomains...) fmt.Fprintln(dst, "search", strings.Join(newDomains, " ")) replaced = true } if !replaced { fmt.Fprintln(dst, "search", strings.Join(searchDomains, " ")) } return nil }
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
package templates import (
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
"fmt" "go/ast" "go/types" "maps" "reflect" "sort" "strconv" "strings" . "github.com/dave/jennifer/jen" ) func (ps *parseState) parseGoStruct(t *types.Struct, named *types.Named) (*parsedObjectType, error) { spec := &parsedObjectType{ goType: t, } if named == nil { return nil, fmt.Errorf("struct types must be named") } spec.name = named.Obj().Name() if spec.name == "" { return nil, fmt.Errorf("struct types must be named") } objectIsDaggerGenerated := ps.isDaggerGenerated(named.Obj()) goFuncTypes := []*types.Func{} methodSet := types.NewMethodSet(types.NewPointer(named)) for i := 0; i < methodSet.Len(); i++ { methodObj := methodSet.At(i).Obj() if ps.isDaggerGenerated(methodObj) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
continue } if objectIsDaggerGenerated { return nil, fmt.Errorf("cannot define methods on objects from outside this module") } goFuncType, ok := methodObj.(*types.Func) if !ok { return nil, fmt.Errorf("expected method to be a func, got %T", methodObj) } if !goFuncType.Exported() { continue } goFuncTypes = append(goFuncTypes, goFuncType) } if objectIsDaggerGenerated { return nil, nil } sort.Slice(goFuncTypes, func(i, j int) bool { return goFuncTypes[i].Pos() < goFuncTypes[j].Pos() }) for _, goFuncType := range goFuncTypes { funcTypeSpec, err := ps.parseGoFunc(named, goFuncType) if err != nil { return nil, fmt.Errorf("failed to parse method %s: %w", goFuncType.Name(), err) } spec.methods = append(spec.methods, funcTypeSpec) } astSpec, err := ps.astSpecForNamedType(named)
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
if err != nil { return nil, fmt.Errorf("failed to find decl for named type %s: %w", spec.name, err) } spec.doc = astSpec.Doc.Text() astStructType, ok := astSpec.Type.(*ast.StructType) if !ok { return nil, fmt.Errorf("expected type spec to be a struct, got %T", astSpec.Type) } astFields := unpackASTFields(astStructType.Fields) for i := 0; i < t.NumFields(); i++ { field := t.Field(i) if !field.Exported() { continue } fieldSpec := &fieldSpec{goType: field.Type()} fieldSpec.typeSpec, err = ps.parseGoTypeReference(field.Type(), nil, false) if err != nil { return nil, fmt.Errorf("failed to parse field type: %w", err) } fieldSpec.goName = field.Name() fieldSpec.name = fieldSpec.goName tag := reflect.StructTag(t.Tag(i)) if dt := tag.Get("json"); dt != "" { dt, _, _ = strings.Cut(dt, ",") if dt == "-" { continue }
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
fieldSpec.name = dt } docPragmas, docComment := parsePragmaComment(astFields[i].Doc.Text()) linePragmas, lineComment := parsePragmaComment(astFields[i].Comment.Text()) comment := strings.TrimSpace(docComment) if comment == "" { comment = strings.TrimSpace(lineComment) } pragmas := make(map[string]string) maps.Copy(pragmas, docPragmas) maps.Copy(pragmas, linePragmas) if v, ok := pragmas["private"]; ok { if v == "" { fieldSpec.isPrivate = true } else { fieldSpec.isPrivate, _ = strconv.ParseBool(v) } } fieldSpec.doc = comment spec.fields = append(spec.fields, fieldSpec) } if ps.isMainModuleObject(spec.name) && ps.constructor != nil { spec.constructor, err = ps.parseGoFunc(nil, ps.constructor) if err != nil { return nil, fmt.Errorf("failed to parse constructor: %w", err) } } return spec, nil } type parsedObjectType struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
name string doc string fields []*fieldSpec methods []*funcTypeSpec constructor *funcTypeSpec goType *types.Struct } var _ NamedParsedType = &parsedObjectType{} func (spec *parsedObjectType) TypeDefCode() (*Statement, error) { withObjectArgsCode := []Code{ Lit(spec.name), } withObjectOptsCode := []Code{} if spec.doc != "" { withObjectOptsCode = append(withObjectOptsCode, Id("Description").Op(":").Lit(strings.TrimSpace(spec.doc))) } if len(withObjectOptsCode) > 0 { withObjectArgsCode = append(withObjectArgsCode, Id("TypeDefWithObjectOpts").Values(withObjectOptsCode...)) } typeDefCode := Qual("dag", "TypeDef").Call().Dot("WithObject").Call(withObjectArgsCode...) for _, method := range spec.methods { fnTypeDefCode, err := method.TypeDefCode() if err != nil { return nil, fmt.Errorf("failed to convert method %s to function def: %w", method.name, err) } typeDefCode = dotLine(typeDefCode, "WithFunction").Call(Add(Line(), fnTypeDefCode)) } for _, field := range spec.fields { if field.isPrivate {
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
continue } fieldTypeDefCode, err := field.typeSpec.TypeDefCode() if err != nil { return nil, fmt.Errorf("failed to convert field type: %w", err) } withFieldArgsCode := []Code{ Lit(field.name), fieldTypeDefCode, } if field.doc != "" { withFieldArgsCode = append(withFieldArgsCode, Id("TypeDefWithFieldOpts").Values( Id("Description").Op(":").Lit(field.doc), )) } typeDefCode = dotLine(typeDefCode, "WithField").Call(withFieldArgsCode...) } if spec.constructor != nil { fnTypeDefCode, err := spec.constructor.TypeDefCode() if err != nil { return nil, fmt.Errorf("failed to convert constructor to function def: %w", err) } typeDefCode = dotLine(typeDefCode, "WithConstructor").Call(Add(Line(), fnTypeDefCode)) } return typeDefCode, nil } func (spec *parsedObjectType) GoType() types.Type { return spec.goType }
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
func (spec *parsedObjectType) GoSubTypes() []types.Type { var subTypes []types.Type for _, method := range spec.methods { subTypes = append(subTypes, method.GoSubTypes()...) } for _, field := range spec.fields { if field.isPrivate { continue } subTypes = append(subTypes, field.typeSpec.GoSubTypes()...) } if spec.constructor != nil { subTypes = append(subTypes, spec.constructor.GoSubTypes()...) } return subTypes } func (spec *parsedObjectType) Name() string { return spec.name } /* Extra generated code needed for the object implementation. Right now, this is just an UnmarshalJSON method. This is needed because objects may have fields of an interface type, which the JSON unmarshaller can't handle on its own. Instead, this custom unmarshaller will unmarshal the JSON into a struct where all the fields are concrete types, including the underlying concrete struct implementation of any interface fields. After it unmarshals into that, it copies the fields to the real object fields, handling any special cases around interface conversions (e.g. converting a slice of structs to a slice of interfaces). e.g.: func (r *Test) UnmarshalJSON(bs []byte) error {
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
var concrete struct { Iface *customIfaceImpl IfaceList []*customIfaceImpl OtherIfaceList []*otherIfaceImpl } err := json.Unmarshal(bs, &concrete) if err != nil { return err } r.Iface = concrete.Iface.toIface() r.IfaceList = convertSlice(concrete.IfaceList, (*customIfaceImpl).toIface) r.OtherIfaceList = convertSlice(concrete.OtherIfaceList, (*otherIfaceImpl).toIface) return nil } */ func (spec *parsedObjectType) ImplementationCode() (*Statement, error) { concreteFields := make([]Code, 0, len(spec.fields)) setFieldCodes := make([]*Statement, 0, len(spec.fields)) for _, field := range spec.fields { fieldTypeCode, err := spec.concreteFieldTypeCode(field.typeSpec) if err != nil { return nil, fmt.Errorf("failed to generate field type code: %w", err) } fieldCode := Id(field.goName).Add(fieldTypeCode) if field.goName != field.name { fieldCode.Tag(map[string]string{"json": field.name}) } concreteFields = append(concreteFields, fieldCode) setFieldCode, err := spec.setFieldsFromConcreteStructCode(field) if err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
return nil, fmt.Errorf("failed to generate set field code: %w", err) } setFieldCodes = append(setFieldCodes, setFieldCode) } return Func().Params(Id("r").Op("*").Id(spec.name)). Id("UnmarshalJSON"). Params(Id("bs").Id("[]byte")). Params(Id("error")). BlockFunc(func(g *Group) { g.Var().Id("concrete").Struct(concreteFields...) g.Id("err").Op(":=").Id("json").Dot("Unmarshal").Call(Id("bs"), Op("&").Id("concrete")) g.If(Id("err").Op("!=").Nil()).Block(Return(Id("err"))) for _, setFieldCode := range setFieldCodes { g.Add(setFieldCode) } g.Return(Nil()) }), nil } /* The code for the type of a field in the concrete struct unmarshalled into. Mainly needs to handle interface types, which need to be converted to their concrete struct implementations. */ func (spec *parsedObjectType) concreteFieldTypeCode(typeSpec ParsedType) (*Statement, error) { s := Empty() switch typeSpec := typeSpec.(type) { case *parsedPrimitiveType: if typeSpec.isPtr { s.Op("*") } if typeSpec.alias != "" {
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
s.Id(typeSpec.alias) } else { s.Id(typeSpec.GoType().String()) } case *parsedSliceType: fieldTypeCode, err := spec.concreteFieldTypeCode(typeSpec.underlying) if err != nil { return nil, fmt.Errorf("failed to generate slice field type code: %w", err) } s.Index().Add(fieldTypeCode) case *parsedObjectTypeReference: if typeSpec.isPtr { s.Op("*") } s.Id(typeSpec.name) case *parsedIfaceTypeReference: s.Op("*").Id(formatIfaceImplName(typeSpec.name)) default: return nil, fmt.Errorf("unsupported concrete field type %T", typeSpec) } return s, nil } /* The code for setting the fields of the real object from the concrete struct unmarshalled into. e.g.: r.Iface = concrete.Iface.toIface() r.IfaceList = convertSlice(concrete.IfaceList, (*customIfaceImpl).toIface) */ func (spec *parsedObjectType) setFieldsFromConcreteStructCode(field *fieldSpec) (*Statement, error) { s := Empty() switch typeSpec := field.typeSpec.(type) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,369
๐Ÿž Optional type in module field yields error
### What is the issue? When using `Optional` in a module field type (combined with constructors) Dagger yields the following error: > Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor" ### Dagger version dagger v0.9.5 (registry.dagger.io/engine) darwin/arm64 ### Steps to reproduce Create a module with optional fields: ```go type Ci struct { GithubActor Optional[string] GithubToken Optional[*Secret] } func New( // Actor the token belongs to. githubActor Optional[string], // Token to access the GitHub API. githubToken Optional[*Secret], ) *Ci { return &Ci{ GithubActor: githubActor, GithubToken: githubToken, } } ``` Run `dagger call` with any parameters. ### Log output Error: query module objects: json: error calling MarshalJSON for type *dagger.Module: returned error 400 Bad Request: failed to get schema for module "ci": failed to create field: failed to get mod type for field "githubActor"
https://github.com/dagger/dagger/issues/6369
https://github.com/dagger/dagger/pull/6370
42d9870f1535cff19dc2ca85134aee6ffcd3f0dd
25955caab25bc35543ebcd1c0746c857533c7021
2024-01-07T22:56:03Z
go
2024-01-09T11:09:04Z
cmd/codegen/generator/go/templates/module_objects.go
case *parsedPrimitiveType, *parsedObjectTypeReference: s.Id("r").Dot(field.goName).Op("=").Id("concrete").Dot(field.goName) case *parsedSliceType: switch underlyingTypeSpec := typeSpec.underlying.(type) { case *parsedIfaceTypeReference: s.Id("r").Dot(field.goName).Op("=").Id("convertSlice").Call( Id("concrete").Dot(field.goName), Parens(Op("*").Id(formatIfaceImplName(underlyingTypeSpec.name))).Dot("toIface"), ) default: s.Id("r").Dot(field.goName).Op("=").Id("concrete").Dot(field.goName) } case *parsedIfaceTypeReference: s.Id("r").Dot(field.goName).Op("=").Id("concrete").Dot(field.goName).Dot("toIface").Call() default: return nil, fmt.Errorf("unsupported field type %T", typeSpec) } return s, nil } type fieldSpec struct { name string doc string typeSpec ParsedType isPrivate bool goName string goType types.Type }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
package core import ( "bytes" "fmt" "os" "path/filepath" "strconv" "strings" "testing" "time" "dagger.io/dagger" "github.com/dagger/dagger/core" "github.com/dagger/dagger/engine/buildkit" "github.com/dagger/dagger/internal/testutil" "github.com/moby/buildkit/identity" "github.com/stretchr/testify/require" ) func TestFile(t *testing.T) { t.Parallel() var res struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
Directory struct { WithNewFile struct { File struct { ID core.FileID Contents string } } } } err := testutil.Query( `{ directory { withNewFile(path: "some-file", contents: "some-content") { file(path: "some-file") { id contents } } } }`, &res, nil) require.NoError(t, err) require.NotEmpty(t, res.Directory.WithNewFile.File.ID) require.Equal(t, "some-content", res.Directory.WithNewFile.File.Contents) } func TestDirectoryFile(t *testing.T) { t.Parallel() var res struct { Directory struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
WithNewFile struct { Directory struct { File struct { ID core.FileID Contents string } } } } } err := testutil.Query( `{ directory { withNewFile(path: "some-dir/some-file", contents: "some-content") { directory(path: "some-dir") { file(path: "some-file") { id contents } } } } }`, &res, nil) require.NoError(t, err) require.NotEmpty(t, res.Directory.WithNewFile.Directory.File.ID) require.Equal(t, "some-content", res.Directory.WithNewFile.Directory.File.Contents) } func TestFileSize(t *testing.T) { t.Parallel() var res struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
Directory struct { WithNewFile struct { File struct { ID core.FileID Size int } } } } err := testutil.Query( `{ directory { withNewFile(path: "some-file", contents: "some-content") { file(path: "some-file") { id size } } } }`, &res, nil) require.NoError(t, err) require.NotEmpty(t, res.Directory.WithNewFile.File.ID) require.Equal(t, len("some-content"), res.Directory.WithNewFile.File.Size) } func TestFileExport(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
t.Parallel() wd := t.TempDir() targetDir := t.TempDir() c, ctx := connect(t, dagger.WithWorkdir(wd)) file := c.Container().From(alpineImage).File("/etc/alpine-release") t.Run("to absolute path", func(t *testing.T) { dest := filepath.Join(targetDir, "some-file") ok, err := file.Export(ctx, dest) require.NoError(t, err) require.True(t, ok) contents, err := os.ReadFile(dest) require.NoError(t, err) require.Equal(t, "3.18.2\n", string(contents)) entries, err := ls(targetDir) require.NoError(t, err) require.Len(t, entries, 1) }) t.Run("to relative path", func(t *testing.T) { ok, err := file.Export(ctx, "some-file") require.NoError(t, err) require.True(t, ok) contents, err := os.ReadFile(filepath.Join(wd, "some-file")) require.NoError(t, err) require.Equal(t, "3.18.2\n", string(contents)) entries, err := ls(wd)
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
require.NoError(t, err) require.Len(t, entries, 1) }) t.Run("to path in outer dir", func(t *testing.T) { ok, err := file.Export(ctx, "../some-file") require.Error(t, err) require.False(t, ok) }) t.Run("to absolute dir", func(t *testing.T) { ok, err := file.Export(ctx, targetDir) require.Error(t, err) require.False(t, ok) }) t.Run("to workdir", func(t *testing.T) { ok, err := file.Export(ctx, ".") require.Error(t, err) require.False(t, ok) }) t.Run("file under subdir", func(t *testing.T) { dir := c.Directory(). WithNewFile("/file", "content1"). WithNewFile("/subdir/file", "content2") file := dir.File("/subdir/file") dest := filepath.Join(targetDir, "da-file") _, err := file.Export(ctx, dest) require.NoError(t, err) contents, err := os.ReadFile(dest) require.NoError(t, err) require.Equal(t, "content2", string(contents)) dir = dir.Directory("/subdir")
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
file = dir.File("file") dest = filepath.Join(targetDir, "da-file-2") _, err = file.Export(ctx, dest) require.NoError(t, err) contents, err = os.ReadFile(dest) require.NoError(t, err) require.Equal(t, "content2", string(contents)) }) t.Run("file larger than max chunk size", func(t *testing.T) { maxChunkSize := buildkit.MaxFileContentsChunkSize fileSizeBytes := maxChunkSize*4 + 1 _, err := c.Container().From(alpineImage).WithExec([]string{"sh", "-c", fmt.Sprintf("dd if=/dev/zero of=/file bs=%d count=1", fileSizeBytes)}). File("/file").Export(ctx, "some-pretty-big-file") require.NoError(t, err) stat, err := os.Stat(filepath.Join(wd, "some-pretty-big-file")) require.NoError(t, err) require.EqualValues(t, fileSizeBytes, stat.Size()) }) t.Run("file permissions are retained", func(t *testing.T) { _, err := c.Directory().WithNewFile("/file", "#!/bin/sh\necho hello", dagger.DirectoryWithNewFileOpts{ Permissions: 0744, }).File("/file").Export(ctx, "some-executable-file") require.NoError(t, err) stat, err := os.Stat(filepath.Join(wd, "some-executable-file")) require.NoError(t, err) require.EqualValues(t, 0744, stat.Mode().Perm()) }) } func TestFileWithTimestamps(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
t.Parallel() c, ctx := connect(t) reallyImportantTime := time.Date(1985, 10, 26, 8, 15, 0, 0, time.UTC) file := c.Directory(). WithNewFile("sub-dir/sub-file", "sub-content"). File("sub-dir/sub-file"). WithTimestamps(int(reallyImportantTime.Unix())) ls, err := c.Container(). From(alpineImage). WithMountedFile("/file", file). WithEnvVariable("RANDOM", identity.NewID()). WithExec([]string{"stat", "/file"}). Stdout(ctx) require.NoError(t, err) require.Contains(t, ls, "Access: 1985-10-26 08:15:00.000000000 +0000") require.Contains(t, ls, "Modify: 1985-10-26 08:15:00.000000000 +0000") } func TestFileContents(t *testing.T) { t.Parallel() c, ctx := connect(t) testFiles := []struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
size int hash string }{ {size: buildkit.MaxFileContentsChunkSize / 2}, {size: buildkit.MaxFileContentsChunkSize}, {size: buildkit.MaxFileContentsChunkSize * 2}, {size: buildkit.MaxFileContentsSize + 1}, } tempDir := t.TempDir() for i, testFile := range testFiles { filename := strconv.Itoa(i) dest := filepath.Join(tempDir, filename) var buf bytes.Buffer for i := 0; i < testFile.size; i++ { buf.WriteByte('a') } err := os.WriteFile(dest, buf.Bytes(), 0o600) require.NoError(t, err) testFiles[i].hash = computeMD5FromReader(&buf) } hostDir := c.Host().Directory(tempDir) alpine := c.Container(). From(alpineImage).WithDirectory(".", hostDir) for i, testFile := range testFiles { filename := strconv.Itoa(i) contents, err := alpine.File(filename).Contents(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/integration/file_test.go
if testFile.size > buildkit.MaxFileContentsSize { require.Error(t, err) continue } require.NoError(t, err) contentsHash := computeMD5FromReader(strings.NewReader(contents)) require.Equal(t, testFile.hash, contentsHash) } } func TestFileSync(t *testing.T) { t.Parallel() c, ctx := connect(t) t.Run("triggers error", func(t *testing.T) { _, err := c.Directory().File("baz").Sync(ctx) require.Error(t, err) require.Contains(t, err.Error(), "no such file") _, err = c.Container().From(alpineImage).File("/bar").Sync(ctx) require.Error(t, err) require.Contains(t, err.Error(), "no such file") }) t.Run("allows chaining", func(t *testing.T) { file, err := c.Directory().WithNewFile("foo", "bar").File("foo").Sync(ctx) require.NoError(t, err) contents, err := file.Contents(ctx) require.NoError(t, err) require.Equal(t, "bar", contents) }) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/schema/file.go
package schema import ( "context" "github.com/dagger/dagger/core" "github.com/dagger/dagger/dagql" ) type fileSchema struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/schema/file.go
srv *dagql.Server } var _ SchemaResolvers = &fileSchema{} func (s *fileSchema) Install() { dagql.Fields[*core.Query]{ dagql.Func("file", s.file). Deprecated("Use loadFileFromID instead."), }.Install(s.srv) dagql.Fields[*core.File]{ Syncer[*core.File](). Doc(`Force evaluation in the engine.`), dagql.Func("contents", s.contents). Doc(`Retrieves the contents of the file.`), dagql.Func("size", s.size). Doc(`Retrieves the size of the file, in bytes.`), dagql.Func("export", s.export). Impure("Writes to the local host."). Doc(`Writes the file to a file path on the host.`). ArgDoc("path", `Location of the written directory (e.g., "output.txt").`). ArgDoc("allowParentDirPath", `If allowParentDirPath is true, the path argument can be a directory path, in which case the file will be created in that directory.`), dagql.Func("withTimestamps", s.withTimestamps). Doc(`Retrieves this file with its created/modified timestamps set to the given time.`). ArgDoc("timestamp", `Timestamp to set dir/files in.`, `Formatted in seconds following Unix epoch (e.g., 1672531199).`), }.Install(s.srv) } type fileArgs struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/schema/file.go
ID core.FileID } func (s *fileSchema) file(ctx context.Context, parent *core.Query, args fileArgs) (*core.File, error) { val, err := args.ID.Load(ctx, s.srv) if err != nil { return nil, err } return val.Self, nil } func (s *fileSchema) contents(ctx context.Context, file *core.File, args struct{}) (dagql.String, error) { content, err := file.Contents(ctx) if err != nil { return "", err } return dagql.NewString(string(content)), nil } func (s *fileSchema) size(ctx context.Context, file *core.File, args struct{}) (dagql.Int, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
core/schema/file.go
info, err := file.Stat(ctx) if err != nil { return 0, err } return dagql.NewInt(int(info.Size_)), nil } type fileExportArgs struct { Path string AllowParentDirPath bool `default:"false"` } func (s *fileSchema) export(ctx context.Context, parent *core.File, args fileExportArgs) (dagql.Boolean, error) { err := parent.Export(ctx, args.Path, args.AllowParentDirPath) if err != nil { return false, err } return true, nil } type fileWithTimestampsArgs struct { Timestamp int } func (s *fileSchema) withTimestamps(ctx context.Context, parent *core.File, args fileWithTimestampsArgs) (*core.File, error) { return parent.WithTimestamps(ctx, args.Timestamp) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
package dagger import ( "context" "encoding/json" "errors" "fmt" "reflect" "github.com/Khan/genqlient/graphql" "github.com/vektah/gqlparser/v2/gqlerror" "dagger.io/dagger/querybuilder" ) func assertNotNil(argName string, value any) { if reflect.ValueOf(value).IsNil() { panic(fmt.Sprintf("unexpected nil pointer for argument %q", argName)) } } func ptr[T any](v T) *T { return &v } type Optional[T any] struct { value T isSet bool } func Opt[T any](v T) Optional[T] {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
return Optional[T]{value: v, isSet: true} } func OptEmpty[T any]() Optional[T] { return Optional[T]{} } func (o *Optional[T]) Get() (T, bool) { if o == nil { var empty T return empty, false } return o.value, o.isSet } func (o *Optional[T]) GetOr(defaultValue T) T { if o == nil { return defaultValue } if o.isSet { return o.value } return defaultValue } func (o *Optional[T]) MarshalJSON() ([]byte, error) { return json.Marshal(&o.value) } func (o *Optional[T]) UnmarshalJSON(dt []byte) error { o.isSet = true return json.Unmarshal(dt, &o.value) } type DaggerObject querybuilder.GraphQLMarshaller func convertSlice[I any, O any](in []I, f func(I) O) []O {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
out := make([]O, len(in)) for i, v := range in { out[i] = f(v) } return out } func convertOptionalVal[I any, O any](opt Optional[I], f func(I) O) Optional[O] { if !opt.isSet { return Optional[O]{} } return Optional[O]{value: f(opt.value), isSet: true} } func getCustomError(err error) error { var gqlErr *gqlerror.Error if !errors.As(err, &gqlErr) { return nil }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
ext := gqlErr.Extensions typ, ok := ext["_type"].(string) if !ok { return nil } if typ == "EXEC_ERROR" { e := &ExecError{ original: err, } if code, ok := ext["exitCode"].(float64); ok { e.ExitCode = int(code) } if args, ok := ext["cmd"].([]interface{}); ok { cmd := make([]string, len(args)) for i, v := range args { cmd[i] = v.(string) } e.Cmd = cmd } if stdout, ok := ext["stdout"].(string); ok { e.Stdout = stdout } if stderr, ok := ext["stderr"].(string); ok { e.Stderr = stderr } return e } return nil } type ExecError struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
original error Cmd []string ExitCode int Stdout string Stderr string } func (e *ExecError) Error() string { return fmt.Sprintf( "%s\nStdout:\n%s\nStderr:\n%s", e.Message(), e.Stdout, e.Stderr, ) } func (e *ExecError) Message() string { return e.original.Error() } func (e *ExecError) Unwrap() error { return e.original
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
} type CacheVolumeID string type ContainerID string type DirectoryID string type EnvVariableID string type FieldTypeDefID string type FileID string type FunctionArgID string type FunctionCallArgValueID string type FunctionCallID string type FunctionID string type GeneratedCodeID string type GitRefID string type GitRepositoryID string type HostID string type InterfaceTypeDefID string type JSON string type LabelID string type ListTypeDefID string type ModuleConfigID string type ModuleID string type ObjectTypeDefID string type Platform string type PortID string type SecretID string type ServiceID string type SocketID string type TypeDefID string type Void string type BuildArg struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Name string `json:"name"` Value string `json:"value"` } type PipelineLabel struct { Name string `json:"name"` Value string `json:"value"` } type PortForward struct { Backend int `json:"backend"` Frontend int `json:"frontend"` Protocol NetworkProtocol `json:"protocol,omitempty"` } type CacheVolume struct { q *querybuilder.Selection c graphql.Client id *CacheVolumeID }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
func (r *CacheVolume) ID(ctx context.Context) (CacheVolumeID, error) { if r.id != nil { return *r.id, nil } q := r.q.Select("id") var response CacheVolumeID q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *CacheVolume) XXX_GraphQLType() string { return "CacheVolume" } func (r *CacheVolume) XXX_GraphQLIDType() string { return "CacheVolumeID" } func (r *CacheVolume) XXX_GraphQLID(ctx context.Context) (string, error) { id, err := r.ID(ctx) if err != nil { return "", err } return string(id), nil } func (r *CacheVolume) MarshalJSON() ([]byte, error) { id, err := r.ID(context.Background()) if err != nil { return nil, err } return json.Marshal(id) } type Container struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
q *querybuilder.Selection c graphql.Client envVariable *string export *bool id *ContainerID imageRef *string label *string platform *Platform publish *string shellEndpoint *string stderr *string stdout *string sync *ContainerID user *string workdir *string } type WithContainerFunc func(r *Container) *Container func (r *Container) With(f WithContainerFunc) *Container { return f(r) } func (r *Container) AsService() *Service { q := r.q.Select("asService") return &Service{ q: q, c: r.c, } } type ContainerAsTarballOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
PlatformVariants []*Container ForcedCompression ImageLayerCompression MediaTypes ImageMediaTypes } func (r *Container) AsTarball(opts ...ContainerAsTarballOpts) *File { q := r.q.Select("asTarball") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].PlatformVariants) { q = q.Arg("platformVariants", opts[i].PlatformVariants) } if !querybuilder.IsZeroValue(opts[i].ForcedCompression) { q = q.Arg("forcedCompression", opts[i].ForcedCompression) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
if !querybuilder.IsZeroValue(opts[i].MediaTypes) { q = q.Arg("mediaTypes", opts[i].MediaTypes) } } return &File{ q: q, c: r.c, } } type ContainerBuildOpts struct { Dockerfile string Target string BuildArgs []BuildArg Secrets []*Secret } func (r *Container) Build(context *Directory, opts ...ContainerBuildOpts) *Container { assertNotNil("context", context) q := r.q.Select("build") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Dockerfile) { q = q.Arg("dockerfile", opts[i].Dockerfile)
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
} if !querybuilder.IsZeroValue(opts[i].Target) { q = q.Arg("target", opts[i].Target) } if !querybuilder.IsZeroValue(opts[i].BuildArgs) { q = q.Arg("buildArgs", opts[i].BuildArgs) } if !querybuilder.IsZeroValue(opts[i].Secrets) { q = q.Arg("secrets", opts[i].Secrets) } } q = q.Arg("context", context) return &Container{ q: q, c: r.c, } } func (r *Container) DefaultArgs(ctx context.Context) ([]string, error) { q := r.q.Select("defaultArgs") var response []string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) Directory(path string) *Directory { q := r.q.Select("directory") q = q.Arg("path", path) return &Directory{
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
q: q, c: r.c, } } func (r *Container) Entrypoint(ctx context.Context) ([]string, error) { q := r.q.Select("entrypoint") var response []string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) EnvVariable(ctx context.Context, name string) (string, error) { if r.envVariable != nil { return *r.envVariable, nil } q := r.q.Select("envVariable") q = q.Arg("name", name) var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) EnvVariables(ctx context.Context) ([]EnvVariable, error) { q := r.q.Select("envVariables") q = q.Select("id") type envVariables struct { Id EnvVariableID } convert := func(fields []envVariables) []EnvVariable { out := []EnvVariable{} for i := range fields { val := EnvVariable{id: &fields[i].Id}
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
val.q = querybuilder.Query().Select("loadEnvVariableFromID").Arg("id", fields[i].Id) val.c = r.c out = append(out, val) } return out } var response []envVariables q = q.Bind(&response) err := q.Execute(ctx, r.c) if err != nil { return nil, err } return convert(response), nil } func (r *Container) ExperimentalWithAllGPUs() *Container { q := r.q.Select("experimentalWithAllGPUs") return &Container{ q: q, c: r.c, } } func (r *Container) ExperimentalWithGPU(devices []string) *Container { q := r.q.Select("experimentalWithGPU") q = q.Arg("devices", devices) return &Container{ q: q, c: r.c, } } type ContainerExportOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
PlatformVariants []*Container ForcedCompression ImageLayerCompression MediaTypes ImageMediaTypes } func (r *Container) Export(ctx context.Context, path string, opts ...ContainerExportOpts) (bool, error) { if r.export != nil { return *r.export, nil } q := r.q.Select("export") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].PlatformVariants) { q = q.Arg("platformVariants", opts[i].PlatformVariants) } if !querybuilder.IsZeroValue(opts[i].ForcedCompression) { q = q.Arg("forcedCompression", opts[i].ForcedCompression)
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
} if !querybuilder.IsZeroValue(opts[i].MediaTypes) { q = q.Arg("mediaTypes", opts[i].MediaTypes) } } q = q.Arg("path", path) var response bool q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) ExposedPorts(ctx context.Context) ([]Port, error) { q := r.q.Select("exposedPorts") q = q.Select("id") type exposedPorts struct { Id PortID } convert := func(fields []exposedPorts) []Port { out := []Port{} for i := range fields { val := Port{id: &fields[i].Id} val.q = querybuilder.Query().Select("loadPortFromID").Arg("id", fields[i].Id) val.c = r.c out = append(out, val) } return out } var response []exposedPorts q = q.Bind(&response) err := q.Execute(ctx, r.c)
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
if err != nil { return nil, err } return convert(response), nil } func (r *Container) File(path string) *File { q := r.q.Select("file") q = q.Arg("path", path) return &File{ q: q, c: r.c, } } func (r *Container) From(address string) *Container { q := r.q.Select("from") q = q.Arg("address", address) return &Container{ q: q, c: r.c, } } func (r *Container) ID(ctx context.Context) (ContainerID, error) { if r.id != nil { return *r.id, nil } q := r.q.Select("id") var response ContainerID q = q.Bind(&response) return response, q.Execute(ctx, r.c) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
func (r *Container) XXX_GraphQLType() string { return "Container" } func (r *Container) XXX_GraphQLIDType() string { return "ContainerID" } func (r *Container) XXX_GraphQLID(ctx context.Context) (string, error) { id, err := r.ID(ctx) if err != nil { return "", err } return string(id), nil } func (r *Container) MarshalJSON() ([]byte, error) { id, err := r.ID(context.Background()) if err != nil { return nil, err } return json.Marshal(id) } func (r *Container) ImageRef(ctx context.Context) (string, error) { if r.imageRef != nil { return *r.imageRef, nil } q := r.q.Select("imageRef") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type ContainerImportOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Tag string } func (r *Container) Import(source *File, opts ...ContainerImportOpts) *Container { assertNotNil("source", source) q := r.q.Select("import") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Tag) { q = q.Arg("tag", opts[i].Tag) } } q = q.Arg("source", source) return &Container{ q: q, c: r.c, } } func (r *Container) Label(ctx context.Context, name string) (string, error) { if r.label != nil { return *r.label, nil } q := r.q.Select("label") q = q.Arg("name", name) var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) Labels(ctx context.Context) ([]Label, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
q := r.q.Select("labels") q = q.Select("id") type labels struct { Id LabelID } convert := func(fields []labels) []Label { out := []Label{} for i := range fields { val := Label{id: &fields[i].Id} val.q = querybuilder.Query().Select("loadLabelFromID").Arg("id", fields[i].Id) val.c = r.c out = append(out, val) } return out } var response []labels q = q.Bind(&response) err := q.Execute(ctx, r.c) if err != nil { return nil, err } return convert(response), nil } func (r *Container) Mounts(ctx context.Context) ([]string, error) { q := r.q.Select("mounts") var response []string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } type ContainerPipelineOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Description string Labels []PipelineLabel } func (r *Container) Pipeline(name string, opts ...ContainerPipelineOpts) *Container { q := r.q.Select("pipeline") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Description) { q = q.Arg("description", opts[i].Description) } if !querybuilder.IsZeroValue(opts[i].Labels) { q = q.Arg("labels", opts[i].Labels) } } q = q.Arg("name", name) return &Container{ q: q, c: r.c, } } func (r *Container) Platform(ctx context.Context) (Platform, error) { if r.platform != nil { return *r.platform, nil } q := r.q.Select("platform") var response Platform q = q.Bind(&response)
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
return response, q.Execute(ctx, r.c) } type ContainerPublishOpts struct { PlatformVariants []*Container ForcedCompression ImageLayerCompression MediaTypes ImageMediaTypes } func (r *Container) Publish(ctx context.Context, address string, opts ...ContainerPublishOpts) (string, error) { if r.publish != nil { return *r.publish, nil } q := r.q.Select("publish") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].PlatformVariants) { q = q.Arg("platformVariants", opts[i].PlatformVariants) } if !querybuilder.IsZeroValue(opts[i].ForcedCompression) { q = q.Arg("forcedCompression", opts[i].ForcedCompression) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
if !querybuilder.IsZeroValue(opts[i].MediaTypes) { q = q.Arg("mediaTypes", opts[i].MediaTypes) } } q = q.Arg("address", address) var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) Rootfs() *Directory { q := r.q.Select("rootfs") return &Directory{ q: q, c: r.c, } } func (r *Container) ShellEndpoint(ctx context.Context) (string, error) { if r.shellEndpoint != nil { return *r.shellEndpoint, nil } q := r.q.Select("shellEndpoint") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) Stderr(ctx context.Context) (string, error) { if r.stderr != nil { return *r.stderr, nil }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
q := r.q.Select("stderr") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) Stdout(ctx context.Context) (string, error) { if r.stdout != nil { return *r.stdout, nil } q := r.q.Select("stdout") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) Sync(ctx context.Context) (*Container, error) { q := r.q.Select("sync") return r, q.Execute(ctx, r.c) } func (r *Container) User(ctx context.Context) (string, error) { if r.user != nil { return *r.user, nil } q := r.q.Select("user") var response string q = q.Bind(&response) return response, q.Execute(ctx, r.c) } func (r *Container) WithDefaultArgs(args []string) *Container { q := r.q.Select("withDefaultArgs") q = q.Arg("args", args)
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
return &Container{ q: q, c: r.c, } } type ContainerWithDirectoryOpts struct { Exclude []string Include []string Owner string } func (r *Container) WithDirectory(path string, directory *Directory, opts ...ContainerWithDirectoryOpts) *Container { assertNotNil("directory", directory) q := r.q.Select("withDirectory") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Exclude) { q = q.Arg("exclude", opts[i].Exclude) } if !querybuilder.IsZeroValue(opts[i].Include) { q = q.Arg("include", opts[i].Include) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
if !querybuilder.IsZeroValue(opts[i].Owner) { q = q.Arg("owner", opts[i].Owner) } } q = q.Arg("path", path) q = q.Arg("directory", directory) return &Container{ q: q, c: r.c, } } type ContainerWithEntrypointOpts struct { KeepDefaultArgs bool } func (r *Container) WithEntrypoint(args []string, opts ...ContainerWithEntrypointOpts) *Container { q := r.q.Select("withEntrypoint") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].KeepDefaultArgs) { q = q.Arg("keepDefaultArgs", opts[i].KeepDefaultArgs) } } q = q.Arg("args", args) return &Container{ q: q, c: r.c, } } type ContainerWithEnvVariableOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Expand bool } func (r *Container) WithEnvVariable(name string, value string, opts ...ContainerWithEnvVariableOpts) *Container { q := r.q.Select("withEnvVariable") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Expand) { q = q.Arg("expand", opts[i].Expand) } } q = q.Arg("name", name) q = q.Arg("value", value) return &Container{ q: q, c: r.c, } } type ContainerWithExecOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
SkipEntrypoint bool Stdin string RedirectStdout string RedirectStderr string ExperimentalPrivilegedNesting bool InsecureRootCapabilities bool } func (r *Container) WithExec(args []string, opts ...ContainerWithExecOpts) *Container { q := r.q.Select("withExec") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].SkipEntrypoint) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
q = q.Arg("skipEntrypoint", opts[i].SkipEntrypoint) } if !querybuilder.IsZeroValue(opts[i].Stdin) { q = q.Arg("stdin", opts[i].Stdin) } if !querybuilder.IsZeroValue(opts[i].RedirectStdout) { q = q.Arg("redirectStdout", opts[i].RedirectStdout) } if !querybuilder.IsZeroValue(opts[i].RedirectStderr) { q = q.Arg("redirectStderr", opts[i].RedirectStderr) } if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) { q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting) } if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) { q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities) } } q = q.Arg("args", args) return &Container{ q: q, c: r.c, } } type ContainerWithExposedPortOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Protocol NetworkProtocol Description string } func (r *Container) WithExposedPort(port int, opts ...ContainerWithExposedPortOpts) *Container { q := r.q.Select("withExposedPort") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Protocol) { q = q.Arg("protocol", opts[i].Protocol) } if !querybuilder.IsZeroValue(opts[i].Description) { q = q.Arg("description", opts[i].Description) } } q = q.Arg("port", port) return &Container{ q: q, c: r.c, } } type ContainerWithFileOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Permissions int Owner string } func (r *Container) WithFile(path string, source *File, opts ...ContainerWithFileOpts) *Container { assertNotNil("source", source) q := r.q.Select("withFile") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Permissions) { q = q.Arg("permissions", opts[i].Permissions) } if !querybuilder.IsZeroValue(opts[i].Owner) { q = q.Arg("owner", opts[i].Owner) } } q = q.Arg("path", path) q = q.Arg("source", source)
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
return &Container{ q: q, c: r.c, } } func (r *Container) WithFocus() *Container { q := r.q.Select("withFocus") return &Container{ q: q, c: r.c, } } func (r *Container) WithLabel(name string, value string) *Container { q := r.q.Select("withLabel") q = q.Arg("name", name) q = q.Arg("value", value) return &Container{ q: q, c: r.c, } } type ContainerWithMountedCacheOpts struct { Source *Directory Sharing CacheSharingMode
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Owner string } func (r *Container) WithMountedCache(path string, cache *CacheVolume, opts ...ContainerWithMountedCacheOpts) *Container { assertNotNil("cache", cache) q := r.q.Select("withMountedCache") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Source) { q = q.Arg("source", opts[i].Source) } if !querybuilder.IsZeroValue(opts[i].Sharing) { q = q.Arg("sharing", opts[i].Sharing) } if !querybuilder.IsZeroValue(opts[i].Owner) { q = q.Arg("owner", opts[i].Owner) } } q = q.Arg("path", path) q = q.Arg("cache", cache) return &Container{ q: q, c: r.c, } } type ContainerWithMountedDirectoryOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Owner string } func (r *Container) WithMountedDirectory(path string, source *Directory, opts ...ContainerWithMountedDirectoryOpts) *Container { assertNotNil("source", source) q := r.q.Select("withMountedDirectory") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Owner) { q = q.Arg("owner", opts[i].Owner) } } q = q.Arg("path", path) q = q.Arg("source", source) return &Container{ q: q, c: r.c, } } type ContainerWithMountedFileOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Owner string } func (r *Container) WithMountedFile(path string, source *File, opts ...ContainerWithMountedFileOpts) *Container { assertNotNil("source", source) q := r.q.Select("withMountedFile") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Owner) { q = q.Arg("owner", opts[i].Owner) } } q = q.Arg("path", path) q = q.Arg("source", source) return &Container{ q: q, c: r.c, } } type ContainerWithMountedSecretOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Owner string Mode int } func (r *Container) WithMountedSecret(path string, source *Secret, opts ...ContainerWithMountedSecretOpts) *Container { assertNotNil("source", source) q := r.q.Select("withMountedSecret") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Owner) { q = q.Arg("owner", opts[i].Owner) } if !querybuilder.IsZeroValue(opts[i].Mode) { q = q.Arg("mode", opts[i].Mode) } }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
q = q.Arg("path", path) q = q.Arg("source", source) return &Container{ q: q, c: r.c, } } func (r *Container) WithMountedTemp(path string) *Container { q := r.q.Select("withMountedTemp") q = q.Arg("path", path) return &Container{ q: q, c: r.c, } } type ContainerWithNewFileOpts struct { Contents string Permissions int Owner string } func (r *Container) WithNewFile(path string, opts ...ContainerWithNewFileOpts) *Container { q := r.q.Select("withNewFile") for i := len(opts) - 1; i >= 0; i-- {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
if !querybuilder.IsZeroValue(opts[i].Contents) { q = q.Arg("contents", opts[i].Contents) } if !querybuilder.IsZeroValue(opts[i].Permissions) { q = q.Arg("permissions", opts[i].Permissions) } if !querybuilder.IsZeroValue(opts[i].Owner) { q = q.Arg("owner", opts[i].Owner) } } q = q.Arg("path", path) return &Container{ q: q, c: r.c, } } func (r *Container) WithRegistryAuth(address string, username string, secret *Secret) *Container { assertNotNil("secret", secret) q := r.q.Select("withRegistryAuth") q = q.Arg("address", address) q = q.Arg("username", username) q = q.Arg("secret", secret) return &Container{ q: q, c: r.c, } }
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
func (r *Container) WithRootfs(directory *Directory) *Container { assertNotNil("directory", directory) q := r.q.Select("withRootfs") q = q.Arg("directory", directory) return &Container{ q: q, c: r.c, } } func (r *Container) WithSecretVariable(name string, secret *Secret) *Container { assertNotNil("secret", secret) q := r.q.Select("withSecretVariable") q = q.Arg("name", name) q = q.Arg("secret", secret) return &Container{ q: q, c: r.c, } } func (r *Container) WithServiceBinding(alias string, service *Service) *Container { assertNotNil("service", service) q := r.q.Select("withServiceBinding") q = q.Arg("alias", alias) q = q.Arg("service", service) return &Container{ q: q, c: r.c, } } type ContainerWithUnixSocketOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,416
โœจ Add name field to File
### What are you trying to do? Files passed to `dagger call` currently does not preserve the name of a file passed to it. ### Why is this important to you? Some tools often require the original file name (for example: Spectral requires the file name do determine the file type) Discussed it with @sipsma here: https://discord.com/channels/707636530424053791/1120503349599543376/1195832958150529165 ### How are you currently working around this? I pass the original file name to the module.
https://github.com/dagger/dagger/issues/6416
https://github.com/dagger/dagger/pull/6431
61bf06b970402efa254a40f13c4aee98adfbdb42
c716a042f290b11c6122d247f8b31651adb5f1d0
2024-01-13T21:04:31Z
go
2024-01-17T16:17:48Z
sdk/go/dagger.gen.go
Owner string } func (r *Container) WithUnixSocket(path string, source *Socket, opts ...ContainerWithUnixSocketOpts) *Container { assertNotNil("source", source) q := r.q.Select("withUnixSocket") for i := len(opts) - 1; i >= 0; i-- { if !querybuilder.IsZeroValue(opts[i].Owner) { q = q.Arg("owner", opts[i].Owner) } } q = q.Arg("path", path)