FATE icon indicating copy to clipboard operation
FATE copied to clipboard

自定义方法报has no attribute

Open iceicei opened this issue 1 year ago • 11 comments

我想修改评分卡的计算逻辑,所以新写了一个方法,但是一直报AttributeError: type object 'Scorecard' has no attribute 'compute_credit_score_v2'。然后我尝试只是把Scorecard.compute_credit_score改成Scorecard.compute_credit_score_v2,其他都没改动同样会报这个错。 f156ca08afde0829f3f92d9a5c34615 2cb602020e6555dc464581da909db85 我又尝试在原方法上修改,只是删除了原方法的一些参数,运行时报TypeError: compute_credit_score() missing 5 required positional arguments: 'offset', 'factor', 'factor_base', 'upper_limit_value', and 'lower_limit_value',但是我修改的方法根本没有这些参数。 af4fafeee5787a624ff0c7a22cea2dd 请问,我需要怎么自定义方法,或者还需要在哪里修改呢?

iceicei avatar Dec 13 '23 01:12 iceicei

请问下你是用什么方法部署的?

talkingwallace avatar Dec 13 '23 06:12 talkingwallace

请问下你是用什么方法部署的?

使用Ansible部署的FATE1.11.0版本,计算和存储使用的默认的eggroll。只是自定义方法甚至只修改了方法名,和部署方式有关系吗...我还尝试过把模块和方法名加到eggroll/conf/whitelist.json中,还是没用。

iceicei avatar Dec 13 '23 06:12 iceicei

是多机器部署吗

talkingwallace avatar Dec 13 '23 07:12 talkingwallace

是多机器部署吗 Guest一台,Host一台。

iceicei avatar Dec 13 '23 07:12 iceicei

是多机器部署吗

我只是在python/federatedml/statistic/scorecard/score_transformer.py:95中将静态方法Scorecard.compute_credit_score改名后缀加_v2,其它都没动,为啥还会报错。难道eggroll在导入模块的时候有特殊处理吗。

iceicei avatar Dec 13 '23 07:12 iceicei

两台机器的代码都改了么?eggroll应该是没有啥特别要求才对的

talkingwallace avatar Dec 13 '23 08:12 talkingwallace

两台机器的代码都改了么?eggroll应该是没有啥特别要求才对的

我又测试了一下,两台机器都是同步修改的。只修改了federatedml/statistic/scorecard/score_transformer.py:48 federatedml.statistic.scorecard.score_transformer.Scorecard.compute_credit_score,这个方法的方法名。然后就has no attribute。感觉是不是哪里有装饰器进行了处理。

iceicei avatar Dec 13 '23 10:12 iceicei

[ERROR] [2023-12-13 17:18:32,587] [202312131716440083370] [15495:139853814658880] - [task_executor.run] [line:265]: ('Failed to call command: CommandURI(_uri=v1/egg-pair/runTask) to endpoint: xxx.xxx.xxx.xxx:36780, caused by: ', <_InactiveRpcError of RPC that terminated with:

details = "Exception calling application: 

==== detail start, at 20231213.171328.468 ==== Traceback (most recent call last): File "/opt/data/projects/fate/eggroll/python/eggroll/core/utils.py", line 187, in wrapper return func(*args, **kw) File "/opt/data/projects/fate/eggroll/python/eggroll/roll_pair/egg_pair.py", line 265, in run_task self._run_unary(map_values_wrapper, task) File "/opt/data/projects/fate/eggroll/python/eggroll/roll_pair/egg_pair.py", line 131, in _run_unary func(rb, input_key_serdes, input_value_serdes, wb) File "/opt/data/projects/fate/eggroll/python/eggroll/roll_pair/egg_pair.py", line 263, in map_values_wrapper output_writebatch.put(k_bytes, value_serdes.serialize(f(v))) File "/opt/data/projects/fate/fate/python/federatedml/statistic/scorecard/score_transformer.py", line 97, in upper_limit_value, AttributeError: type object 'Scorecard' has no attribute 'compute_credit_score_v99'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/data/projects/fate/eggroll/python/eggroll/core/utils.py", line 187, in wrapper return func(*args, **kw) File "/opt/data/projects/fate/eggroll/python/eggroll/core/command/command_service.py", line 30, in call call_result = CommandRouter.get_instance()
File "/opt/data/projects/fate/eggroll/python/eggroll/core/command/command_router.py", line 94, in dispatch raise e File "/opt/data/projects/fate/eggroll/python/eggroll/core/command/command_router.py", line 91, in dispatch call_result = _method(_instance, *deserialized_args) File "/opt/data/projects/fate/eggroll/python/eggroll/core/utils.py", line 194, in wrapper raise RuntimeError(msg) RuntimeError:

iceicei avatar Dec 13 '23 10:12 iceicei

我是改完之后直接在部署机上将对应的脚本覆盖。

iceicei avatar Dec 13 '23 10:12 iceicei

重启下eggroll,fateflow服务

dylan-fan avatar Dec 15 '23 11:12 dylan-fan

重启下eggroll,fateflow服务

我之前遇到这个问题的时候都会用source /data/projects/common/supervisord/service.sh restart all,但是好像没什么用。这个问题是偶发的,有时候突然又好了。因为是自己部署的环境专门用来测试,所以测试时就直接覆盖对应python脚本了。

iceicei avatar Dec 20 '23 01:12 iceicei