[GitHub] [airflow] kaxil commented on a change in pull request #21445: [de]serialize resources on task correctly

2022-02-15 Thread GitBox


kaxil commented on a change in pull request #21445:
URL: https://github.com/apache/airflow/pull/21445#discussion_r806190710



##
File path: airflow/utils/operator_resources.py
##
@@ -134,3 +142,37 @@ def __eq__(self, other):
 
 def __repr__(self):
 return str(self.__dict__)
+
+def to_dict(self):
+return {
+'cpus': self.cpus.to_dict(),
+'ram': self.ram.to_dict(),
+'disk': self.disk.to_dict(),
+'gpus': self.gpus.to_dict(),
+}
+
+def to_json(self):
+return json.dumps(self.to_dict())
+
+@classmethod
+def is_operator_resources_json_string(cls, json_str: str):

Review comment:
   I don't have a suggestion for better name, but would love a shorter name 
if someone has a suggestion.




-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [airflow] kaxil commented on a change in pull request #21445: [de]serialize resources on task correctly

2022-02-14 Thread GitBox


kaxil commented on a change in pull request #21445:
URL: https://github.com/apache/airflow/pull/21445#discussion_r806190710



##
File path: airflow/utils/operator_resources.py
##
@@ -134,3 +142,37 @@ def __eq__(self, other):
 
 def __repr__(self):
 return str(self.__dict__)
+
+def to_dict(self):
+return {
+'cpus': self.cpus.to_dict(),
+'ram': self.ram.to_dict(),
+'disk': self.disk.to_dict(),
+'gpus': self.gpus.to_dict(),
+}
+
+def to_json(self):
+return json.dumps(self.to_dict())
+
+@classmethod
+def is_operator_resources_json_string(cls, json_str: str):

Review comment:
   I don't have a suggestion for better name, but would love a shorter name 
if someone has a suggestion.




-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org