Repository: PrefectHQ/prefect

Issue:
document loading external files with `Git` storage
## Current behavior
<!-- Please describe how the feature works today -->
No docs


## Proposed behavior
<!-- Please describe your proposed change to the current behavior -->
Create an example doc illustration how to use `Git` storage to load external files (non-python files) from a repo with `Git` storage



## Example
<!-- Please give an example of how the enhancement would be useful -->



Discussion:
@zangell44 can you include the sketch you recently provided in support in this thread for now? Just the raw code will be helpful for some people running into this.

Resolving patch:
diff --git a/src/prefect/utilities/storage.py b/src/prefect/utilities/storage.py
--- a/src/prefect/utilities/storage.py
+++ b/src/prefect/utilities/storage.py
@@ -4,7 +4,7 @@
 import sys
 import warnings
 from operator import attrgetter
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Dict, Any
 from distutils.version import LooseVersion
 
 import cloudpickle
@@ -82,7 +82,9 @@ def extract_flow_from_file(
         raise ValueError("Provide either `file_path` or `file_contents`.")
 
     # Load objects from file into dict
-    exec_vals = {}  # type: ignore
+    # if a file_path has been provided, provide __file__ as a global variable
+    # so it resolves correctly during extraction
+    exec_vals: Dict[str, Any] = {"__file__": file_path} if file_path else {}
     exec(contents, exec_vals)
 
     # Grab flow name from values loaded via exec


Test patch:
diff --git a/tests/utilities/test_storage.py b/tests/utilities/test_storage.py
--- a/tests/utilities/test_storage.py
+++ b/tests/utilities/test_storage.py
@@ -1,6 +1,7 @@
 import os
 import sys
 import types
+import textwrap
 
 import pytest
 import cloudpickle
@@ -61,6 +62,28 @@ def flow_path(self, tmpdir):
 
         return full_path
 
+    @pytest.fixture
+    def flow_path_with_additional_file(self, tmpdir):
+        contents = """\
+        from prefect import Flow
+        from pathlib import Path
+
+        with open(str(Path(__file__).resolve().parent)+"/test.txt", "r") as f:
+            name = f.read()
+        
+        f2 = Flow(name)
+        """
+
+        full_path = os.path.join(tmpdir, "flow.py")
+
+        with open(full_path, "w") as f:
+            f.write(textwrap.dedent(contents))
+
+        with open(os.path.join(tmpdir, "test.txt"), "w") as f:
+            f.write("test-flow")
+
+        return full_path
+
     def test_extract_flow_from_file_path(self, flow_path):
         flow = extract_flow_from_file(file_path=flow_path)
         assert flow.name == "flow-1"
@@ -72,6 +95,13 @@ def test_extract_flow_from_file_path(self, flow_path):
         flow = extract_flow_from_file(file_path=flow_path, flow_name="flow-2")
         assert flow.name == "flow-2"
 
+    def test_extract_flow_from_file_path_can_load_files_from_same_directory(
+        self, flow_path_with_additional_file
+    ):
+        flow = extract_flow_from_file(file_path=flow_path_with_additional_file)
+        assert flow.name == "test-flow"
+        assert flow.run().is_successful()
+
     def test_extract_flow_from_file_contents(self, flow_path):
         with open(flow_path, "r") as f:
             contents = f.read()