@@ -724,7 +724,8 @@ def assets(self) -> DictTuple[str, Asset] | SyftError:
724724 all_inputs = {}
725725 inputs = self .input_policy_init_kwargs or {}
726726 for vals in inputs .values ():
727- all_inputs .update (vals )
727+ # Only keep UIDs, filter out Constants
728+ all_inputs .update ({k : v for k , v in vals .items () if isinstance (v , UID )})
728729
729730 # map the action_id to the asset
730731 used_assets : list [Asset ] = []
@@ -753,20 +754,47 @@ def action_objects(self) -> dict:
753754 action_objects = {
754755 arg_name : str (uid )
755756 for arg_name , uid in all_inputs .items ()
756- if arg_name not in self .assets .keys ()
757+ if arg_name not in self .assets .keys () and isinstance ( uid , UID )
757758 }
758759
759760 return action_objects
760761
762+ @property
763+ def constants (self ) -> dict [str , Constant ]:
764+ if not self .input_policy_init_kwargs :
765+ return {}
766+
767+ all_inputs = {}
768+ for vals in self .input_policy_init_kwargs .values ():
769+ all_inputs .update (vals )
770+
771+ # filter out the assets
772+ constants = {
773+ arg_name : item
774+ for arg_name , item in all_inputs .items ()
775+ if isinstance (item , Constant )
776+ }
777+
778+ return constants
779+
761780 @property
762781 def inputs (self ) -> dict :
763782 inputs = {}
764- if self .action_objects :
765- inputs ["action_objects" ] = self .action_objects
766- if self .assets :
783+
784+ assets = self .assets
785+ action_objects = self .action_objects
786+ constants = self .constants
787+ if action_objects :
788+ inputs ["action_objects" ] = action_objects
789+ if assets :
767790 inputs ["assets" ] = {
768791 argument : asset ._get_dict_for_user_code_repr ()
769- for argument , asset in self .assets .items ()
792+ for argument , asset in assets .items ()
793+ }
794+ if self .constants :
795+ inputs ["constants" ] = {
796+ argument : constant ._get_dict_for_user_code_repr ()
797+ for argument , constant in constants .items ()
770798 }
771799 return inputs
772800
0 commit comments