> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Access parent directories from a flow

To import a shared package from a parent directory in a Metaflow flow, add a [symlink](https://en.wikipedia.org/wiki/Symbolic_link) in the directory containing your flow script, pointing at the shared package. Metaflow dereferences symlinks when packaging your code (supported since Metaflow 2.5.2), so the package is included whether the flow runs locally or remotely.

<Tree>
  <Tree.Folder name="flow_type_1" defaultOpen>
    <Tree.File name="flow1.py" />

    <Tree.Folder name="common_utils" defaultOpen />
  </Tree.Folder>

  <Tree.Folder name="flow_type_2" defaultOpen>
    <Tree.File name="flow2.py" />

    <Tree.Folder name="common_utils" defaultOpen />
  </Tree.Folder>

  <Tree.Folder name="common_utils" defaultOpen>
    <Tree.File name="__init__.py" />

    <Tree.File name="some_module.py" />
  </Tree.Folder>
</Tree>

In the tree above, `flow_type_1/common_utils` and `flow_type_2/common_utils` are symlinks pointing to the shared `common_utils` package.

<Steps>
  <Step title="Define the shared package">
    Define the functionality you want to reuse in a Python package:

    ```py title="common_utils/some_module.py" theme={null}
    import os

    def general_function():
        return os.getcwd()
    ```

    Export it from the package's initialization module:

    ```py title="common_utils/__init__.py" theme={null}
    from .some_module import general_function
    ```
  </Step>

  <Step title="Create the symlink">
    Add a symlink from the flow's directory to the shared package:

    ```sh theme={null}
    ln -s ../common_utils flow_type_1/common_utils
    ```
  </Step>

  <Step title="Import the package in a flow">
    ```py title="flow_type_1/flow1.py" expandable theme={null}
    from metaflow import FlowSpec, step

    class Flow1(FlowSpec):

        @step
        def start(self):
            from common_utils import general_function
            self.result = general_function()
            self.next(self.end)

        @step
        def end(self):
            pass

    if __name__ == "__main__":
        Flow1()
    ```
  </Step>

  <Step title="Run the flow">
    ```sh theme={null}
    python flow_type_1/flow1.py run
    ```

    The run completes successfully, with the shared package included:

    ```text theme={null}
    Workflow starting (run-id 1666836481231665):
    [1666836481231665/start/1 (pid 81716)] Task is starting.
    [1666836481231665/start/1 (pid 81716)] Task finished successfully.
    [1666836481231665/end/2 (pid 81719)] Task is starting.
    [1666836481231665/end/2 (pid 81719)] Task finished successfully.
    Done!
    ```
  </Step>
</Steps>
