wenjin272 commented on code in PR #314:
URL: https://github.com/apache/flink-agents/pull/314#discussion_r2536107099


##########
plan/src/main/java/org/apache/flink/agents/plan/resourceprovider/PythonResourceProvider.java:
##########
@@ -46,6 +54,27 @@ public PythonResourceProvider(
         this.module = module;
         this.clazz = clazz;
         this.kwargs = kwargs;
+        this.descriptor = null;
+    }
+
+    public PythonResourceProvider(String name, ResourceType type, 
ResourceDescriptor descriptor) {
+        super(name, type);
+        module = descriptor.getArgument("module");
+        if (module == null || module.isEmpty()) {
+            throw new IllegalArgumentException("module should not be null or 
empty.");
+        }
+        clazz = descriptor.getArgument("clazz");
+        if (clazz == null || clazz.isEmpty()) {
+            throw new IllegalArgumentException("clazz should not be null or 
empty.");
+        }
+        this.kwargs = new HashMap<>(descriptor.getInitialArguments());
+        this.kwargs.remove("module");
+        this.kwargs.remove("clazz");

Review Comment:
   Maybe we can just simplify the code to 
   ```
   this.kwargs = new HashMap<>(descriptor.getInitialArguments());
   module = (String) kwargs.remove("module");
   if (module == null || module.isEmpty()) {
       throw new IllegalArgumentException("module should not be null or 
empty.");
   }
   clazz = (String) kwargs.remove("clazz");
   if (clazz == null || clazz.isEmpty()) {
       throw new IllegalArgumentException("clazz should not be null or empty.");
   }
   ```



-- 
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]

Reply via email to