<#8749 feature: `meltano state clear --all` argume...
# meltano-repo-activity
g
#8749 feature:
meltano state clear --all
argument
Issue created by fauzxan Feature scope CLI (options, error messages, logging, etc.) Context Need the ability to clear all states. In particular, currently if one wants to automate the clearing of states table, we are required to 1. list all the states using
meltano state list
2. then use this list to loop through all the states and run
meltano state clear --force {state}
for each state One can carry out the above, with either CLI, or python code: CLI meltano state list | xargs -I {} sh -c 'meltano state clear --force {}` Python state_ids = subprocess.run( [ "meltano", "state", "list" ] ) state_list = state_ids.stdout.split('\n') state_clear_command = ';'.join([f"meltano state clear --force {state}" for state in state_list if state]) subprocess.call(state_clear_command, shell=True) Request It would be convenient if someone could help introduce the functionality to add
--all
flag for meltano state command. I believe we could modify this part of the code: meltano/src/meltano/cli/state.py Lines 311 to 321 in</meltano/meltano/commit/2f53237190ca463292dfe67d2b93731968fdc6ab|2f53237> | @meltano_state.command(cls=InstrumentedCmd, name="clear") | | ------------------------------------------------------------------------------- | | @prompt_for_confirmation(prompt="This will clear state for the job. Continue?") | | @click.argument("state-id") | | @pass_project(migrate=True) | | @click.pass_context | | def clear_state(ctx: click.Context, project: Project, state_id: str) -> None: | | """Clear state.""" | | state_service: StateService = ( | | state_service_from_state_id(project, state_id) or ctx.obj[STATE_SERVICE_KEY] | | ) | | state_service.clear_state(state_id) | to accept a new parameter
--all
that: 1. Carries out a intention check
Are you sure you want to do this?
which can be overridden with
--force
option 2. Then loops through all the states and clears them I need assistance in confirming if this is the right part of the code to modify for this purpose. I would be happy to know any alternative approaches to this as well! If there are any workarounds for this currently, do let me know! meltano/meltano