Why I am getting this error after upgrade from 2.1...
# ask-marvin
x
Why I am getting this error after upgrade from 2.16.6 to latest 2.19.8? Here is the stack trace. Traceback (most recent call last): File "/home/pentaho/anaconda3/envs/py310/lib/python3.10/site-packages/prefect/engine.py", line 454, in retrieve_flow_then_begin_flow_run parameters = flow.validate_parameters(flow_run.parameters) File "/home/pentaho/anaconda3/envs/py310/lib/python3.10/site-packages/prefect/flows.py", line 510, in validate_parameters args, kwargs = parameters_to_args_kwargs(self.fn, parameters) File "/home/pentaho/anaconda3/envs/py310/lib/python3.10/site-packages/prefect/utilities/callables.py", line 181, in parameters_to_args_kwargs raise SignatureMismatchError.from_bad_params( prefect.exceptions.SignatureMismatchError: Function expects parameters ['args', 'kwargs'] but was provided with parameters ['knownhosts', 'remote_file']
n
hi @Xun Wang can you share your flow?
x
Copy code
@flow(name="ftp_mapping_source_into_db",
      description="Flow FTP to DB default remote file: /ftp/HotelContentExporter_FTPUpload/output/09",
      task_runner=SequentialTaskRunner())
def ftp_mapping_source_into_db(remote_file: str = '/ftp/HotelContentExporter_FTPUpload/output/09',
                               knownhosts: str = None):
        local_file = ftp_to_csv_flow(remote_file, knownhosts)
        source_to_db_task = source_to_db.submit(local_file)
        source_to_db_task.wait()
        summary_of_mapping_sync_src('workflow')
This is from the cloud console for the above error: Validation of flow parameters failed with error: Traceback (most recent call last): File "/home/pentaho/anaconda3/envs/py310/lib/python3.10/site-packages/prefect/engine.py", line 454, in retrieve_flow_then_begin_flow_run parameters = flow.validate_parameters(flow_run.parameters) File "/home/pentaho/anaconda3/envs/py310/lib/python3.10/site-packages/prefect/flows.py", line 510, in validate_parameters args, kwargs = parameters_to_args_kwargs(self.fn, parameters) File "/home/pentaho/anaconda3/envs/py310/lib/python3.10/site-packages/prefect/utilities/callables.py", line 181, in parameters_to_args_kwargs raise SignatureMismatchError.from_bad_params( prefect.exceptions.SignatureMismatchError: Function expects parameters ['args', 'kwargs'] but was provided with parameters ['knownhosts', 'remote_file']
n
can you share the output of the following?
Copy code
prefect deployment inspect your-flow/your-deployment
x
Copy code
{
    'id': '439d81f7-5068-40e6-8227-69e211d9d9cf',
    'created': '2022-09-07T23:56:06.348366+00:00',
    'updated': '2023-10-24T22:05:33.055011+00:00',
    'infra_overrides': {},
    'name': 'vervotech-deployment',
    'version': 'e72dccecba11900b2fd166e5774a0468',
    'description': 'Flow (Vervotech): FTP to DB default remote file: /ftp/HotelContentExporter_FTPUpload/output/09',
    'flow_id': '02fd7e3f-c7e3-4323-b6d0-0da71dff7cb2',
    'schedule': None,
    'is_schedule_active': True,
    'paused': False,
    'schedules': [],
    'parameters': {},
    'pull_steps': None,
    'tags': [],
    'work_queue_name': 'cloud-beta',
    'last_polled': '2024-07-16T17:28:10.139769+00:00',
    'parameter_openapi_schema': {
        'type': 'object',
        'title': 'Parameters',
        'properties': {'knownhosts': {'title': 'knownhosts'}, 'remote_file': {'title': 'remote_file', 'default': '/ftp/HotelContentExporter_FTPUpload/output/09'}}
    },
    'path': '/home/pentaho/prefect2',
    'entrypoint': 'vervotech/vervotech_flow.py:ftp_mapping_source_into_db',
    'manifest_path': None,
    'storage_document_id': None,
    'infrastructure_document_id': '6760e295-85db-42da-9782-18ea923f7355',
    'created_by': None,
    'updated_by': None,
    'work_queue_id': None,
    'enforce_parameter_schema': False,
    'work_pool_name': 'default-agent-pool',
    'status': 'READY',
    'infrastructure': {
        'type': 'process',
        'env': {},
        'labels': {},
        'name': None,
        'command': ['python', '-m', 'prefect.engine'],
        'stream_output': True,
        'working_dir': None,
        'block_type_slug': 'process'
    },
    'automations': []
}
n
hmm thats odd
Copy code
'parameter_openapi_schema': {
        'type': 'object',
        'title': 'Parameters',
        'properties': {'knownhosts': {'title': 'knownhosts'}, 'remote_file': {'title': 'remote_file', 'default': '/ftp/HotelContentExporter_FTPUpload/output/09'}}
    },
this looks right, which makes this error confusing
Copy code
Function expects parameters ['args', 'kwargs']
I will try to reproduce this
๐Ÿ™ 1
x
FYI I have run locally and get pass this particular flow param issue. Since there are many other failures in additional to this one. I rolled back to version 2.17.1 which seems to help. At this moment I have to make the flow to run successfully. Will comeback and check on these errors later. I wonder if the original deployment done long time ago has anything to do with this issue since I noticed the way to perform deployment has changed. Please advise if you have found anything to fix on my side. Also any advice to redeploy those flows developed long time ago (during early release of prefect 2.0).
๐Ÿ™ 1
q
Running into this as well, but on 3.0.0rc11
Untitled.txt
This is weird tbh. I tried to walk through the steps that happen when
engine.py
is ran, which is: 1. using client to load flow run 2. pulling code via
run_steps(deployment.pull_steps)
3. importing flow via
load_flow_from_entrypoint
4. calling
flow_engine._flow_parameters
the way it's called in
run_flow
(passing
flow
and
flow_run
) The last step returns the parameters that were specified in UI when the run was created.
inspect.signature(fn).parameters
(called in
parameters_to_args_kwargs
,
fn=flow.fn
) returns the actual parameters of the function, not args/kwargs.
Indeed, I just ran
python -m prefect.engine FLOW_RUN_ID
on my machine and it succeeded..
Alright, figured it out When
load_flow_from_entrypoint
cannot load a flow (due to a missing dependency for me) it returns a placeholder flow, which, according to a comment is supposed to reraise an exception when ran, but it never gets to since the confusing
SignatureMismatchError
is raised before that moment ๐Ÿ™‚
๐Ÿ‘ 1
x
So it has nothing to do with the parameters passed in. I just didnโ€™t find time to recheck the issue I reported. But will try to redeploy some flowswot 3.0rc once I have a chance. I suspect my flows were deployed long time ago with old ways which the latest >= 2.18 version running with cloud wonโ€™t be able to handle.
n
hi all, this should be fixed on main and 2.x via https://github.com/PrefectHQ/prefect/pull/14669 and the corresponding PR for 3.x so once we release next, this change should take affect
t
I'm still experiencing this issue on
2.17.1
, is that expected? Is there any recommendation for resolving this?
n
hi @Tom Matthews - do you have an MRE for whats going wrong here? i dont totally remember the details here just yet
ahh nevermind
yes that is expected, you'd need to upgrade to the newer version of prefect 2.x that has the fix
2.19.9 or above
t
Perfect thanks, just bumping up to 2.19.9 now
n
๐Ÿ‘