Review using a different port

Hi, would it be possible to make the annotation/review recipees run as on the same prodigy app but on different ports as opposed to spin up two prodigy apps?

Yes! In general, you can modify any recipe port by modifying the prodigy.json config. If you set this for your global config, then this would run for all recipes. Alternatively, you could have a project (folder) specific prodigy.json where it only runs for the folder.

Alternatively, you can also provide an override as an environmental variable like

PRODIGY_PORT=8001 python -m prodigy ...

If you're writing a custom recipe, you can even set that port by modifying the config component in your recipe. If you wanted to make one for the review recipe, you could copy the built-in review recipe (find your Location: path in prodigy stats and find the recipes/review.py file) and then create a new recipe with your modified port.

Hope this helps!

1 Like

Thank you @ryanwesslen, very helpful!

When going with the config option within the recipe, how do I declare the port change? Do I use the port same as in the prodigy.json?

Exactly.

To use the psuedo-code example from the docs:

import prodigy

@prodigy.recipe(
    "my-custom-recipe",
    dataset=("Dataset to save answers to", "positional", None, str),
    view_id=("Annotation interface", "option", "v", str)
)
def my_custom_recipe(dataset, view_id="text"):
    # Load your own streams from anywhere you want
    stream = load_my_custom_stream()

    def update(examples):
        # This function is triggered when Prodigy receives annotations
        print(f"Received {len(examples)} annotations!")

    return {
        "dataset": dataset,
        "view_id": view_id,
        "stream": stream,
        "update": update,
        "config": {  # Additional config settings
            "port": 8001, # change port
        },
    }

What's nice with the custom recipe route is you could also add conditional logic (e.g., if it's one input file, use port 8001 but if it's another, use port 8002) or as an argument for your recipe, for example:

import prodigy

@prodigy.recipe(
    "my-custom-recipe",
    dataset=("Dataset to save answers to", "positional", None, str),
    view_id=("Annotation interface", "option", "v", str),
    port=("Port", "option", "p", int)
)
def my_custom_recipe(dataset, view_id="text"):
    # Load your own streams from anywhere you want
    stream = load_my_custom_stream()

    def update(examples):
        # This function is triggered when Prodigy receives annotations
        print(f"Received {len(examples)} annotations!")

    return {
        "dataset": dataset,
        "view_id": view_id,
        "stream": stream,
        "update": update,
        "config": {  # Additional config settings
            "port": int(port), # change port, make sure int
        },
    }

So now you can specify the port a little easier:

prodigy my-custom-recipe my_dataset --view-id text --port 8000 ---F recipe.py