Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick start #30

Merged
merged 6 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,23 @@ To get this code if you don't already have it:
$ git clone https://github.com/clamsproject/mmif-visualizer
```

## Quick start

If you just want to get the server up and running quickly, the repository contains a shell script `start_visualizer.sh` to immediately launch the visualizer in a container. You can invoke it with the following command:

```
./start_visualizer.sh <data_directory> <mount_directory>
```

* The **required** `data_directory` argument should be the absolute or relative path of the media files on your machine which the MMIF files reference.
* The **optional** `mount_directory` argument should be specified if your MMIF files point to a different directory than where your media files are stored on the host machine. For example, if your video, audio, and text data is stored locally at `/home/archive` but your MMIF files refer to `/data/...`, you should set this variable to `/data`. (If this variable is not set, the mount directory will default to the data directory)

For example, if your media files are stored at `/llc_data` and your MMIF files specify the document location as `"location": "file:///data/...`, you can start the visualizer with the following command:
```
./start_visualizer.sh /llc_data /data
```

The server can then be accessed at `http://localhost:5000/upload`

## Running the server in a container

Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def upload_file(in_mmif):

agent = request.headers.get('User-Agent')
if 'curl' in agent.lower():
return f"Visualization ID is {viz_id}\nYou can access the visualized file at /display/{viz_id}\n"
return f"Visualization ID is {viz_id}\nYou can access the visualized file at {request.url_root}display/{viz_id}\n"
return redirect(f"/display/{viz_id}", code=301)


Expand Down
31 changes: 31 additions & 0 deletions start_visualizer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Check for presence of Docker/Podman engines
if command -v docker &> /dev/null
then
export container_engine=docker
elif command -v podman &> /dev/null
then
export container_engine=podman
else
echo "Error: Docker or Podman not found. Please install container engine and try again."
exit 1
fi
# Return if no inputs passed
if [ -z "$1" ]
then
echo "Error: no data directory specified."
exit 1
fi
# Set data directory to absolute path of input
export datadir=$( cd $1; pwd )
# Set mount directory to data directory if not specified
if [ -z "$2" ]
then
echo "No mount directory specified: defaulting to $datadir"
export mountdir=$datadir
else
export mountdir=$2
fi
# Start visualizer
$container_engine build . -f Containerfile -t clams-mmif-visualizer
$container_engine run -d --name clams-mmif-visualizer --rm -p 5000:5000 -e PYTHONUNBUFFERED=1 -v $datadir:$mountdir -v $datadir:/app/static/$mountdir clams-mmif-visualizer
echo "MMIF Visualizer is running in the background and can be accessed at http://localhost:5000/. To shut it down, run '$container_engine kill clams-mmif-visualizer'"
Loading