Use PyCharm¶
Here are some pointers on how to run most of the core components live in PyCharm when either your local or remote development VM is ready.
Load docker-compose files¶
Minimal Dependencies¶
When dependencies are loaded, you can launch any core components and their dependencies should be satisfied.
- In your project file viewer
- Browse to
assemblyline-base/dev/depends
- Right-click on
docker-compose-minimal.yml
- Select
Create 'depends/docker-compose...'
- Click
OK
- You'll notice on the top right that a new Compose deployment has been created for dependencies. Hit the play button next to it to launch the containers.
Tip
From now on you can just select that Compose deployment for dependencies from the dropdown up top and hit the run button to launch it. It is good practice to Edit the configuration and give it a proper name.
In a new terminal on the VM, run the following commands:
cd ~/git/alv4/assemblyline-base/dev/depends/
sudo docker-compose -f docker-compose-minimal.yml up
Tip
This will take over the terminal and the logs will be displayed there. Hit ctrl-c
when you want to shut the containers down.
If you close the terminal and the containers keep running, run the following commands to shut down the containers:
cd ~/git/alv4/assemblyline-base/dev/depends/
sudo docker-compose -f docker-compose-minimal.yml down
Core services¶
Core services depend on the dependencies in the docker-compose
file. When the core services are loaded you should be able to point a browser at https://IP_OF_VM
and you'll be greeted with a working version of Assemblyline with no services configured.
Note
Default admin user credentials are:
- Username:
admin
- Password:
admin
- In your project file viewer
- Browse to
assemblyline-base/dev/core
- Right-click on
docker-compose.yml
- Select
Create 'core: Compose Deploy...'
- Click
OK
- You'll notice on the top right that a new Compose deployment has been created for core services, hit the play button next to it to launch the containers.
Tip
From now on you can just select that Compose deployment for core components from the dropdown up top and hit the run button to launch it. It is good practice to Edit the configuration and give it a proper name.
In a new terminal on the VM, run the following commands:
cd ~/git/alv4/assemblyline-base/dev/core/
sudo docker-compose up
Tip
This will take over the terminal and the logs will be displayed there. Hit ctrl-c
when you want to shut the containers down.
If you close the terminal and the containers keep running, run the following commands to shut down the containers:
cd ~/git/alv4/assemblyline-base/dev/core/
sudo docker-compose down
Load a single container live¶
Loading a single container is very useful to test a newly create production service container or to launch the frontend while the backend is being debugged.
You can easily load any container live in your Assemblyline Dev environment by following these instructions:
Note
For this demo we will assume that you want to run the service container from the developing an Assemblyline service documentation.
- Click the
Run
menu then selectEdit Configurations...
- Click the
+
button at the top left` - Select "Docker Image"
- In the
Name
field at the top, set the name to:Sample Service - Container
- Set the
Image ID
to:testing/assemblyline-service-sample
- Set the
Container Name
to SampleService - Click the modify options and select
Environment variables
- Add the following environment variable:
SERVICE_API_HOST=http://172.17.0.1:5003
- Click the modify options and select
Run options
- Add the following
Run option
:-network host
- Click
OK
Tip
From now on you can just select the Sample Service - Container
run configuration from the dropdown up top and hit the run button to launch it.
Pycharm Community does not have support for managing Docker containers, therefore you will have to run your containers using a shell
.
In a new terminal on the VM, run the following commands:
docker run --env SERVICE_API_HOST=http://172.17.0.1:5003 --network=host --name SampleService testing/assemblyline-service-sample
Tip
This will take over the terminal and the logs will be displayed there. Hit ctrl-c
when you want to shut the containers down.
Run components live from PyCharm¶
Core Components¶
Most of the core components are going to be as easy to run as finding the component main file then hit Run
or Debug
... All core components require you to run the Minimal Dependencies
docker-compose
file before launching them.
Launching the API Server
- Find the UI main file in the project files browser
assemblyline-ui/assemblyline_ui/app.py
- Right-click on it
- Select either
Run 'app'
orDebug 'app'
Live Services¶
The main exception to very easy-to-run components is debugging services live in the system. Services require you to run two separate components to process files. The two components talk via named pipes in the /tmp folder. Inside the Docker container, this is very easy but debugging this live requires some sacrifices.
Limitations
- You can only run one live debugging service at the time.
- Depending on where you stop them and how you stop them, they don't fully clean up after themselves.
- They require extra configuration, it's not just "click-and-go".
We will show you how to run the Sample service live in the system created in the developing and Assemblyline service documentation. This requires you to run the full infrastructure using the docker-compose
files before executing the steps. (Minimal dependencies and Core services)
Important
Run the following example inside the PyCharm window pointing to the services (~/git/services
)
Example
Setup Task Handler
run configuration if it does not exist:
- Click the "Run" menu then select "Edit Configurations..."
- Click the
+
button at the top left - Click
Python
- The first option in the configuration tab is a drop-down that says
Script path:
click it and chooseModule Name:
- In the box beside it, write:
assemblyline_service_client.task_handler
- In the name box at the top, write
Task Handler
- Click the
OK
Button
Now if you click the green play button beside the newly created Task Handler
run configuration, Task Handler will be waiting for the service to start.
Setup the new service configuration:
- Click the "Run" menu then select "Edit Configurations..."
- Click the
+
button at the top left - Click
Python
- The first option in the configuration tab is a drop-down that says
Script path:
click it and chooseModule Name:
- In the box beside it, write:
assemblyline_v4_service.run_service
- Add
;SERVICE_PATH=sample.Sample
to theEnvironment variables
- Set the working directory to:
assemblyline-service-sample
by pressing the littlefolder
on the right and browsing to that directory - In the name box at the top, write
Sample Service - LIVE
- Click
OK
- Now that dropdown near the top says
Sample Service - LIVE
, click theplay
or thebug
button to eitherRun
orDebug
the service- In the Run or Debug window, the service will be stuck at Waiting for receive task named pipe to be ready.... This is because task_handler shut down after registering the service for the first time.
- Select
task_handler
from the dropdown near the top and click theplay
orbug
button beside it again.- Now both
Sample Service - LIVE
andTask Handler
will stay up and poll for tasks from the service server.
- Now both