Skip to content

Commit

Permalink
Refactor arHttp server install
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaScheller committed Oct 28, 2023
1 parent 50914cf commit da29dfd
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 80 deletions.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ REM Clear current session log
cls
REM Source environment (Uncomment lines starting with "set" if you current env does not have these defined.)
REM set HFS=C:\Program Files\Side Effects Software\<InsertHoudiniVersion>
REM Define Resolver > Has to be one of 'fileResolver'/'pythonResolver'/'hybridResolver'
REM Define Resolver > Has to be one of 'fileResolver'/'pythonResolver'/'cachedResolver'/'httpResolver'
REM set RESOLVER_NAME=fileResolver
REM Clear existing build data and invoke cmake
rmdir /S /Q build
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
clear
# Source environment (Uncomment lines starting with "export" if you current env does not have these defined.)
# export HFS=/opt/<InsertHoudiniVersion>
# Define Resolver > Has to be one of 'fileResolver'/'pythonResolver'/'cachedResolver'
# Define Resolver > Has to be one of 'fileResolver'/'pythonResolver'/'cachedResolver'/'httpResolver'
# export RESOLVER_NAME=fileResolver
# Clear existing build data and invoke cmake
rm -R build
Expand Down
14 changes: 9 additions & 5 deletions docs/src/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ This guide currently covers compiling against Houdini on Linux and Windows. Alte
```

```admonish tip
We also offer a quick install method for Houdini that does the download of the compiled resolvers and environment variable setup for you. This is ideal if you want to get your hands dirty right away and you don't have any C++ knowledge or extensive USD developer knowledge. If you are a small studio, you can jump right in and play around with our "PythonResolver"/"CachedResolver" resolvers and prototype around to make it fit your production needs. See our [Automatic Installation](./installation/automatic_install.md) section for more information.
We also offer a quick install method for Houdini that does the download of the compiled resolvers and environment variable setup for you. This is ideal if you want to get your hands dirty right away and you don't have any C++ knowledge or extensive USD developer knowledge. If you are a small studio, you can jump right in and play around with our resolvers and prototype them further to make it fit your production needs. See our [Automatic Installation](./installation/automatic_install.md) section for more information.
```

## Feature Overview
Asset resolvers that can be compiled via this repository:
- **File Resolver** - A file system based resolver similar to the default resolver with support for custom mapping pairs as well as at runtime modification and refreshing.
- **Python Resolver** - Python based implementation of the file resolver. The goal of this resolver is to enable easier RnD by running all resolver and resolver context related methods in Python. It can be used to quickly inspect resolve calls and to setup prototypes of resolvers that can then later be re-written in C++ as it is easier to code database interactions in Python for initial research.
- **Http Resolver** - A proof of concept http resolver. This is kindly provided and maintained by @charlesfleche in the [arHttp: Offloads USD asset resolution to an HTTP server
](https://github.com/charlesfleche/arHttp) repository. For documentation, feature suggestions and bug reports, please file a ticket there. This repo handles the auto-compilation against DCCs and exposing to the automatic installation update manager UI.
- **Production Resolvers**
- **File Resolver** - A file system based resolver similar to the default resolver with support for custom mapping pairs as well as at runtime modification and refreshing.
- **Cached Resolver** - Still work in progress, more info coming soon.
- **RnD Resolvers**
- **Python Resolver** - Python based implementation of the file resolver. The goal of this resolver is to enable easier RnD by running all resolver and resolver context related methods in Python. It can be used to quickly inspect resolve calls and to setup prototypes of resolvers that can then later be re-written in C++ as it is easier to code database interactions in Python for initial research.
- **Proof Of Concept Resolvers**
- **Http Resolver** - A proof of concept http resolver. This is kindly provided and maintained by @charlesfleche in the [arHttp: Offloads USD asset resolution to an HTTP server
](https://github.com/charlesfleche/arHttp) repository. For documentation, feature suggestions and bug reports, please file a ticket there. This repo handles the auto-compilation against DCCs and exposing to the automatic installation update manager UI.

For more information check out the [building guide](./installation/building.md) as well as the [individual resolvers](./resolvers/overview.md) to see their full functionality.

Expand Down
10 changes: 9 additions & 1 deletion src/HttpResolver/wrap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,12 @@ configure_file(plugInfo.json.in plugInfo.json)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plugInfo.json DESTINATION resources)
install(TARGETS ${AR_HTTPRESOLVER_TARGET_LIB} RUNTIME DESTINATION lib)
# Demo
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../arHttp/src/arHttpSampleServer DESTINATION demo/packages)
set(_server_permissions OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../arHttp/src/arHttpSampleServer DESTINATION demo/packages)
if (WIN32)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/server_install.bat PERMISSIONS ${_server_permissions} DESTINATION demo)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/server_launch.bat PERMISSIONS ${_server_permissions} DESTINATION demo)
else()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/server_install.sh PERMISSIONS ${_server_permissions} DESTINATION demo)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/server_launch.sh PERMISSIONS ${_server_permissions} DESTINATION demo)
endif()
5 changes: 5 additions & 0 deletions src/HttpResolver/wrap/server_install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
REM Create and source virtual env
python -m venv venv
call venv\Scripts\activate.bat
REM Install dependencies (We can't use the pyproject.toml as it depends on .git)
python -m pip install fastapi[all]
5 changes: 5 additions & 0 deletions src/HttpResolver/wrap/server_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Create and source virtual env
python -m venv venv
source venv/bin/activate
# Install dependencies (We can't use the pyproject.toml as it depends on .git)
python -m pip install fastapi[all]
2 changes: 2 additions & 0 deletions src/HttpResolver/wrap/server_launch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REM Start server
venv\Scripts\uvicorn arHttpSampleServer:app --app-dir packages --reload-dir packages --reload
2 changes: 2 additions & 0 deletions src/HttpResolver/wrap/server_launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Start server
venv/bin/uvicorn arHttpSampleServer:app --app-dir packages --reload-dir packages --reload
87 changes: 15 additions & 72 deletions tools/update_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re
import shutil
import ssl
import subprocess
import tempfile
import urllib
import zipfile
Expand All @@ -32,48 +31,6 @@
QT_ROLE_RELEASE = QtCore.Qt.UserRole + 1001


def install_side_effect_httpResolver(platform_name, software_name, resolver_dir_path):
"""The install side effect for the httpResolver.
# ToDo Instead of using 'HFS' for the Houdini install directory, add a software version input arg.
This does the following:
- Create a venv in the ./demo folder
- Install fastapi
- Return run command for server
Args:
platform_name(str): The active platform
software_name(str): The software name
directory_path(str): The resolver directory path
Returns:
str: A command to run before app execution
"""
# Validate
if platform_name == "macos":
raise Exception(
"Platform {} is currently not supported!".format(platform_name)
)

demo_dir_path = os.path.join(resolver_dir_path, "demo")
if not os.path.exists(demo_dir_path):
os.makedirs(demo_dir_path)
python_exe = os.path.join(os.environ["HFS"], "python", "bin", "python")

# Create venv
subprocess.check_call([python_exe, "-m", "venv", "venv"], cwd=demo_dir_path, env={})
venv_python_exe = os.path.join(demo_dir_path, "venv", "bin", "python")
# Install deps (We can't use the pyproject.toml as it depends on .git)
subprocess.check_call([venv_python_exe, "-m", "pip", "install", "fastapi[all]"], cwd=demo_dir_path, env={})
# Command
if platform_name == "linux":
venv_uvicorn_exe = os.path.join(demo_dir_path, "venv", "bin", "uvicorn")
command = "{} arHttpSampleServer:app --reload &".format(venv_uvicorn_exe)
elif platform_name == "win64":
command = 'start "ArHttp Webserver" {} arHttpSampleServer:app --reload'.format(venv_uvicorn_exe)
return command


INSTALL_SIDE_EFFECTS = {"fileResolver": install_side_effect_httpResolver}


class UpdateManagerUI(QtWidgets.QDialog):
def __init__(self, parent):
super(UpdateManagerUI, self).__init__(parent)
Expand Down Expand Up @@ -181,16 +138,16 @@ def initialize(self):
self.resolver_label.setVisible(True)
self.resolver_combobox.setVisible(True)
self.uninstall_button.setVisible(False)
# Query data
self.update_manager.initialize()
# Update UI
for release in self.update_manager.releases:
release_name = release["name"]
item = QtGui.QStandardItem(release_name)
item.setData(release, QT_ROLE_RELEASE)
self.release_combobox.model().appendRow(item)
if not self.update_manager.releases:
self.install_button.setEnabled(False)
# Query data
self.update_manager.initialize()
# Update UI
for release in self.update_manager.releases:
release_name = release["name"]
item = QtGui.QStandardItem(release_name)
item.setData(release, QT_ROLE_RELEASE)
self.release_combobox.model().appendRow(item)
if not self.update_manager.releases:
self.install_button.setEnabled(False)

def directory_lineedit_editingFinished(self):
"""Validate the directory path"""
Expand Down Expand Up @@ -378,8 +335,8 @@ def get_release_data(self, platform_name, software_name, software_version):
filtered_data = []
for release in data:
# Skip pre releases
if release["prerelease"]:
continue
#if release["prerelease"]:
# continue
for asset in release["assets"]:
if asset["content_type"] != "application/zip":
continue
Expand Down Expand Up @@ -509,7 +466,7 @@ def install_release(
# Cleanup other resolvers
for dir_name in os.listdir(directory_path):
if dir_name != resolver_name:
os.rmdir(os.path.join(directory_path, dir_name))
shutil.rmtree(os.path.join(directory_path, dir_name))
# Build launcher
env = {
"PXR_PLUGINPATH_NAME": os.path.join(resolver_dir_path, "resources"),
Expand All @@ -518,9 +475,6 @@ def install_release(
if platform_name == "linux":
env["LD_LIBRARY_PATH"] = os.path.join(resolver_dir_path, "lib")
launch_file_path = os.path.join(directory_path, "launch.sh")
side_effect_command = INSTALL_SIDE_EFFECTS.get(
resolver_name, lambda *args: None
)(platform_name, software_name, resolver_dir_path)
with open(launch_file_path, "w") as launch_file:
lines = []
lines.append("#!/bin/bash")
Expand All @@ -539,27 +493,21 @@ def install_release(
env_name=env_name, env_value=env_value, sep=os.pathsep
)
)
# Side effect command
if side_effect_command:
lines.append(side_effect_command)
# App
lines.append("# Launch Houdini")
lines.append(
"pushd {} && source houdini_setup && popd".format(
os.environ["HFS"]
)
)
# Command
lines.append("# Launch Houdini")
lines.append('houdini -foreground "$@"')
launch_file.writelines(line + "\n" for line in lines)
# Make executable
os.chmod(launch_file_path, 0o0777)
elif platform_name == "win64":
env["PATH"] = os.path.join(resolver_dir_path, "lib")
launch_file_path = os.path.join(directory_path, "launch.bat")
side_effect_command = INSTALL_SIDE_EFFECTS.get(
resolver_name, lambda *args: None
)(platform_name, resolver_dir_path)
with open(launch_file_path, "w") as launch_file:
lines = []
# Environment
Expand All @@ -577,9 +525,6 @@ def install_release(
env_name=env_name, env_value=env_value, sep=os.pathsep
)
)
# Side effect command
if side_effect_command:
lines.append(side_effect_command)
# App & command
lines.append("REM Launch Houdini")
lines.append(os.path.join(os.environ["HFS"], "bin", "houdini"))
Expand Down Expand Up @@ -647,6 +592,4 @@ def run_houdini():
raise Exception("This function can only be run in an active Houdini session.")

dialog = UpdateManagerUI(hou.ui.mainQtWindow())
dialog.exec_()

run_houdini()
dialog.exec_()

0 comments on commit da29dfd

Please sign in to comment.