guydriesen commented on code in PR #39464:
URL: https://github.com/apache/airflow/pull/39464#discussion_r1592835583
##########
airflow/providers/docker/operators/docker_swarm.py:
##########
@@ -225,6 +231,24 @@ def stream_new_logs(last_line_logged, since=0):
sleep(2)
last_line_logged, last_timestamp =
stream_new_logs(last_line_logged, since=last_timestamp)
+ @staticmethod
+ def format_args(args: list[str] | str | None) -> list[str] | None:
+ """Retrieve args.
+
+ The args string is parsed to a list. If it starts with ``[``,
+ the string is treated as a Python literal and parsed into a list.
+
+ :param args: args to the docker service
+
+ :return: the args as list
+ """
+ if isinstance(args, str):
+ if args.strip().startswith("["):
+ return ast.literal_eval(args)
+ else:
+ return shlex.split(args)
+ return args
Review Comment:
The parsing is necessary because docker-py expects the args as a list
(https://docker-py.readthedocs.io/en/stable/api.html#docker.types.ContainerSpec).
I added the string variants as a convenient option, that was not strictly
needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]