microsoft / CyberBattleSim

An experimentation and research platform to investigate the interaction of automated agents in an abstract simulated network environments.
MIT License
1.65k stars 257 forks source link

The instructions are incomplete or the project dependencies are not correct. #12

Closed scsarver closed 3 years ago

scsarver commented 3 years ago

Branch: master

Expected the following to produce output indicating the project is running:

docker build -t cyberbattle:1.1 . docker run -it -v "$(pwd)":/source --rm cyberbattle:1.1 cyberbattle/agents/baseline/run.py

Resulted in:

Traceback (most recent call last): File "cyberbattle/agents/baseline/run.py", line 16, in import torch ModuleNotFoundError: No module named 'torch'

citharus commented 3 years ago

You have to install the requirements. pip install -r requirements.txt

scsarver commented 3 years ago

You have to install the requirements. pip install -r requirements.txt

I have added both of the following statements to the Dockerfile and it still fails in the same spot:

` RUN pip install -r requirements.txt

RUN bash init.sh `

citharus commented 3 years ago

Then try installing torch manually. pip install -U torch

PS.: When doing a multiline code block use ``` at the start and end.

scsarver commented 3 years ago

Updated the docker file to have the following:

RUN pip install -r requirements.txt
RUN pip install --no-cache-dir -U torch
RUN pip install --no-cache-dir -U asciichart asciichartpy
RUN bash init.sh

it fails when running it with the following error:

Traceback (most recent call last):                                                                                                             
  File "cyberbattle/agents/baseline/run.py", line 22, in <module>                                                                              
    import cyberbattle._env.cyberbattle_env as cyberbattle_env
  File "/root/cyberbattle/__init__.py", line 9, in <module>
    from . import agents
  File "/root/cyberbattle/agents/__init__.py", line 9, in <module>
    from .baseline.learner import Learner, AgentWrapper, EnvironmentBounds
  File "/root/cyberbattle/agents/baseline/learner.py", line 9, in <module>
    from .agent_wrapper import AgentWrapper, EnvironmentBounds, Verbosity, ActionTrackingStateAugmentation
  File "/root/cyberbattle/agents/baseline/agent_wrapper.py", line 7, in <module>
    from cyberbattle._env.cyberbattle_env import EnvironmentBounds
  File "/root/cyberbattle/_env/cyberbattle_env.py", line 22, in <module>
    from cyberbattle._env.defender import DefenderAgent
  File "/root/cyberbattle/_env/defender.py", line 11, in <module>
    from cyberbattle.simulation.actions import DefenderAgentActions
  File "/root/cyberbattle/simulation/actions.py", line 19, in <module>
    import IPython.core.display as d
ModuleNotFoundError: No module named 'IPython'
scsarver commented 3 years ago

UPDATE: Updating the Docker file to include the following got me to a point where it would run:

RUN pip install -r requirements.txt
RUN pip install --no-cache-dir -U torch
RUN pip install --no-cache-dir -U asciichart asciichartpy ipython pandas
RUN bash init.sh

To build and run it in docker I ran the following from the projects root directory:

docker build -t cyberbattle:1.1 .
docker run -it -v "$(pwd)":/source --rm cyberbattle:1.1 cyberbattle/agents/baseline/run.py

As a follow up, it is not clear if what I did was hacky and not the intended way to get this to run or not but my suggestion would be to update the readme or requirements in a way that allows someone new like myself a way to run this project.

citharus commented 3 years ago

Please close the issue if there is no problem any more.

scsarver commented 3 years ago

Please close the issue if there is no problem any more.

Is it fixed?

blumu commented 3 years ago

@scsarver I was not able to repro on latest main branch, does it still repro for you? All the missing packages that you are listing (torch, asciichart asciichartpy ipython, pandas) are declared in the requirements.dev.txt file and get installed by install-pythongpackages.sh at https://github.com/microsoft/CyberBattleSim/blob/43a9108d83803ffbc3818b02fa13d9c613c79da8/install-pythonpackages.sh#L14

If this still reproes for you could you share the output of the docker build -t cyberbattle:1.1 . command? I am guessing the init.sh installation script silently fails for some reason and the packages are not properly installed. The docker build output will help debug it.

blumu commented 3 years ago

@scsarver I am closing this issue for now. Please feel free to reopen if you can confirm it reproes on the latest main. Many thanks.