Setting up the required environment
In the project internship we use Python with multiple packages. To simplify the setup, we provide a Docker-Container based on a prebuilt image containing all necessary dependencies for the project internship. The entire Docker-Container is prepared to cover all three exercises of the project internship, you will not need all packages and software for the first exercise.
We provide a package, in which all exercises of the project internship may be solved. The packages contains a test scripts to check the setup and also some utility functions/ classes. The package is meant as a structure to fill with the solutions of all three exercises, however, each group may also create its own different structure.
The package is available as zip file from Moodle.
/project
.-compose.yml # contains the configuration for the Docker-Container provided by us
├── docker# runs the Docker-Container starting a shell inside it
├── run.sh # the main Python package
└── src # folder for exercise 1
├── exercise1 # stub for exercise 1
│ ├── agent_auctioneer.py # stub for exercise 1
│ ├── agent_bidder.py # a folder containing data for exercise 1
│ ├── data
│ │ ├── corpus.txt
│ │ └── sell.txt# stub for exercise 1
│ └── main.py # contains test scripts
├── test # one of the agents used by test_agent.py
│ ├── moin_agent.py # runs a simple agent, testing SPADE and the XMPP server
│ ├── test_agent.py # second agent used by test_agent.py
│ └── visitor_agent.py # contains some util classes and functions
└── utils
├── external.py# write and read (json) files
├── functions.py # seeded random
├── random.py # class downloading articles from wikipedia (uses a cache-file to speed up recurrent fetches of same article) └── wikipedia.py
The package is meant to run as a Python package called
src
. If not using Docker, you may have to change the imports, e.g., change the lines 9-13 in./project/src/test/test_agent.py
.
We strongly recommend to use the Docker-Container provided by us. The container contains all dependencies and is already configured to work with our provided package and source code. However, it is also possible to install the packages on your own and use your own setup.
We prepared an Docker-Image on Docker Hub here. Using Docker and Docker-Compose, the Docker-Container starts as a shell inside the prepared environment.
./run.sh
(or
docker-compose run ia
)
./test/test_agent.py
: Tries to run a simple setup of
three SPADE agents saying or listening for a “Moin!”./project/src/
on the host machine is
mounted at /home/user/src/
inside the container./project/src/exercise1/my-file.py
on the host machine and
run it inside the container via
python ./exercise1/my-file.py
src
is installed as Python package
inside the containerutils
directory is possible with
from src.utils.wikipedia import Wikipedia
We have tested the Docker-Image and Docker-Container together with the scrips on macOS and Linux.
Attention: As everything is running in a stateless Docker-Container, only changes in the folder
/home/user/src/
are stored on the host machine after the container has been terminated!
Install all needed dependencies manually and run the code from our provided package outside of a Docker-Container.
pip3 install spade requests nltk gensim pyLDAvis scikit-learn
python3 -m nltk.downloader punkt stopwords wordnet omw-1.4
python3 ./project/src/test/test_agent.py
: Tries to run
a simple setup of three agents saying and listening for a “Moin!”
src
, change the lines 9-13 in
test_agent.py