Skip to content

Commit

Permalink
App: Enable bundling addtional files into app source (#18980)
Browse files Browse the repository at this point in the history
(cherry picked from commit a9d427c)
  • Loading branch information
ethanwharris authored and Borda committed Nov 14, 2023
1 parent 978f401 commit 5fe681d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lightning/app/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import shutil
import tarfile
import tempfile
from pathlib import Path
Expand All @@ -33,6 +34,7 @@
logger = Logger(__name__)

_PLUGIN_MAX_CLIENT_TRIES: int = 3
_PLUGIN_INTERNAL_DIR_PATH: str = f"{os.environ.get('HOME', '')}/internal"


class LightningPlugin:
Expand Down Expand Up @@ -169,6 +171,10 @@ def _run_plugin(run: _Run) -> Dict[str, Any]:
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=f"Error loading plugin: {str(ex)}."
)

# Allow devs to add files to the app source
if os.path.isdir(_PLUGIN_INTERNAL_DIR_PATH):
shutil.copytree(_PLUGIN_INTERNAL_DIR_PATH, source_path, dirs_exist_ok=True)

# Ensure that apps are dispatched from the temp directory
cwd = os.getcwd()
os.chdir(source_path)
Expand Down

0 comments on commit 5fe681d

Please sign in to comment.