ashb commented on a change in pull request #21445:
URL: https://github.com/apache/airflow/pull/21445#discussion_r806629580
##########
File path: tests/serialization/test_dag_serialization.py
##########
@@ -1654,6 +1673,28 @@ def test_mapped_operator_xcomarg_serde():
assert xcom_arg.operator is serialized_dag.task_dict['op1']
+def test_task_resources_serde():
+ """
+ Test task resources serialization/deserialization.
+ """
+ from airflow.operators.dummy import DummyOperator
+
+ execution_date = datetime(2020, 1, 1)
+ task_id = 'task1'
+ with DAG("test_task_resources", start_date=execution_date) as _:
+ task = DummyOperator(task_id=task_id, resources={"cpus": 0.1, "ram":
2048})
+
+ serialized = SerializedBaseOperator._serialize(task)
+ assert serialized['resources'] == (
+ '{'
+ '"cpus": {"name": "CPU", "qty": 0.1, "units_str": "core(s)"}, '
+ '"disk": {"name": "Disk", "qty": 512, "units_str": "MB"}, '
+ '"gpus": {"name": "GPU", "qty": 0, "units_str": "gpu(s)"}, '
+ '"ram": {"name": "RAM", "qty": 2048, "units_str": "MB"}'
+ '}'
+ )
Review comment:
This shouldn't be a string of a JSON object inside a json object -- it
should be the JSON object directly
--
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]