Hi, here are a few questions about running on remo...
# ask-metaflow
g
Hi, here are a few questions about running on remote: 1. Is there a way to swap between running locally and remote? 2. Can a flow with `batch`/`kubernetes`/`resources` decorator on a step be forced to run locally? 3. Is there a way to specify which step to run remotely when using the
--with
flag? for example something like
Copy code
python flow.py run \
	--with batch:gpu=1,memory=16000,step=gpu_step
1
s
You can create a stand alone pure python decorator that can achieve 1 and 2. With some fiddling, 3 should be feasible as well.
g
I'm just surprised this feature is not available directly with metaflow. In case anyone is interested
Copy code
def custom_batch(**batch_kwargs):
    """
    A wrapper for the @batch decorator that bypasses and runs locally
    if the METAFLOW_FORCE_LOCAL environment variable is set to 'true'.
    """

    def decorator(func):
        if os.getenv("METAFLOW_FORCE_LOCAL", "false").lower() in ["true", "1"]:
            # Bypass behavior: Return the original function without @batch
            @wraps(func)
            def bypassed_func(*args, **kwargs):
                print("METAFLOW_FORCE_LOCAL is set. Running locally without @batch.")
                return func(*args, **kwargs)

            return bypassed_func
        else:
            print("Running with @batch")
            # Normal @batch behavior
            return batch(**batch_kwargs)(func)

    return decorator
🙏 1