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

demoinfocs v4 for CS2 support #293

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11"] #, "3.12-dev"]
go-version: ["1.18", "1.19", "1.20"]
python-version: ["3.11"]
go-version: ["1.21"]
steps:
- name: Checkout awpy library
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The coverage run -m pytest --durations=10 command, which runs the Python tests,

If you do not have the time or bandwidth, you can omit running the test command locally, since Github actions will run them, as well.

### Testing/Coverage
### Testing & Coverage

If you are fixing a bug or adding a new feature make sure to also add [unit tests](https://en.wikipedia.org/wiki/Unit_testing)
that cover the original bug or your new functionality.
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


# awpy
The `awpy` package provides data parsing, analytics and visualization capabilities for Counter-Strike: Global Offensive (CSGO) data. In this repository, you will find the source code, issue tracker and other useful `awpy` information. Please join [our Discord](https://discord.gg/W34XjsSs2H) for discussion around the library and esports analytics. You may visit the documentation [here](https://awpy.readthedocs.io/en/latest/).
The `awpy` package provides data parsing, analytics and visualization capabilities for Counter-Strike (both CSGO and CS2) data. In this repository, you will find the source code, issue tracker and other useful `awpy` information. Please join [our Discord](https://discord.gg/W34XjsSs2H) for discussion around the library and esports analytics. You may visit the documentation [here](https://awpy.readthedocs.io/en/latest/).

## Table of Contents
[Setup and Installation](#setup)
Expand All @@ -19,7 +19,7 @@ The `awpy` package provides data parsing, analytics and visualization capabiliti

## Setup
#### Requirements
`awpy` requires [Python](https://www.python.org/downloads/) >= 3.11 and [Golang](https://golang.org/dl/) >= 1.18. Python acts as a wrapper for the Go code which parses demofiles.
`awpy` requires [Python](https://www.python.org/downloads/) >= 3.11 and [Golang](https://golang.org/dl/) >= 1.21. Python acts as a wrapper for the Go code which parses demofiles.

#### Installation
To install `awpy`, you can run
Expand Down Expand Up @@ -79,14 +79,14 @@ data_df = demo_parser.parse(return_type="df")
Please note that the parser parses _everything_ in the demo. This means that you may have rounds from the warmup (denoted with the `isWarmup` flag), rounds that may have ended in a draw, and other odd-looking rounds. Try using the `DemoParser.clean_rounds()` method to clean up. Note that this is not going to be 100 percent perfect.

### Help! The parser doesn't work or lacks a feature
If you need help with the parser, join [our Discord](https://discord.gg/3JrhKYcEKW). CSGO demos are oftentimes imperfect, but if you ask on Discord, we can try to figure out what is the problem. Please remember to post the error and demo if you can! You can also check the [open issues](https://github.com/pnxenopoulos/awpy/issues) or visit visit [our documentation](https://awpy.readthedocs.io/en/latest/).
If you need help with the parser, join [our Discord](https://discord.gg/3JrhKYcEKW). Counter-Strike demos are oftentimes imperfect, but if you ask on Discord, we can try to figure out what is the problem. Please remember to post the error and demo if you can! You can also check the [open issues](https://github.com/pnxenopoulos/awpy/issues) or visit visit [our documentation](https://awpy.readthedocs.io/en/latest/).

## Examples and Projects
Take a look at the following Jupyter notebooks provided in our `examples/` directory. These will help you get started parsing and analyzing CSGO data.

- [Parsing a CSGO demofile](https://github.com/pnxenopoulos/awpy/blob/main/examples/00_Parsing_a_CSGO_Demofile.ipynb)
- [Basic CSGO analysis](https://github.com/pnxenopoulos/awpy/blob/main/examples/01_Basic_CSGO_Analysis.ipynb)
- [Basic CSGO visualization](https://github.com/pnxenopoulos/awpy/blob/main/examples/02_Basic_CSGO_Visualization.ipynb)
- [Parsing a demofile](https://github.com/pnxenopoulos/awpy/blob/main/examples/00_Parsing_a_CSGO_Demofile.ipynb)
- [Basic analysis](https://github.com/pnxenopoulos/awpy/blob/main/examples/01_Basic_CSGO_Analysis.ipynb)
- [Basic visualization](https://github.com/pnxenopoulos/awpy/blob/main/examples/02_Basic_CSGO_Visualization.ipynb)
- [Working with navigation meshes](https://github.com/pnxenopoulos/awpy/blob/main/examples/03_Working_with_Navigation_Meshes.ipynb)
- [Advanced navigation functionality](https://github.com/pnxenopoulos/awpy/blob/main/examples/04_Advanced_Navigation_Functionality.ipynb)
- [Map control](https://github.com/pnxenopoulos/awpy/blob/main/examples/05_Map_Control_Calculations_And_Visualizations.ipynb)
Expand All @@ -102,10 +102,10 @@ We welcome any contributions from the community. You can visit the [issue page](
```
.
├── awpy
│   ├── analytics # Code for CSGO analytics
│   ├── data # Code for dealing with CSGO map and nav data
│   ├── parser # Code for CSGO demo parser
│   └── visualization # Code for CSGO visualization
│   ├── analytics # Code for analytics
│   ├── data # Code for dealing with map and nav data
│   ├── parser # Code for demo parser
│   └── visualization # Code for visualization
├── doc # Contains documentation files
├── examples # Contains Jupyter Notebooks showing example code
└── tests # Contains tests for the awpy package
Expand Down
2 changes: 2 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ extend-ignore-identifiers-re = [
"MAKAR.*",
# Don't correct the id in notebook
".*ba355586.*",
# Dont correct repo version
".*348096939ba7.*"
]

[type.golangcilint]
Expand Down
8 changes: 4 additions & 4 deletions awpy/parser/demoparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class DemoParser:
json (dict): Dictionary containing the parsed json file

Raises:
ValueError: Raises a ValueError if the Golang version is lower than 1.18
ValueError: Raises a ValueError if the Golang version is lower than 1.21
"""

def __init__(
Expand Down Expand Up @@ -461,7 +461,7 @@ def parse_demo(self) -> None:
Outputs a JSON file to current working directory.

Raises:
ValueError: Raises a ValueError if the Golang version is lower than 1.18
ValueError: Raises a ValueError if the Golang version is lower than 1.21
FileNotFoundError: Raises a FileNotFoundError
if the demofile path does not exist.
"""
Expand All @@ -471,11 +471,11 @@ def parse_demo(self) -> None:
error_message = (
"Error calling Go. "
"Check if Go is installed using 'go version'."
" Need at least v1.18.0."
" Need at least v1.21.0."
)
self.logger.error(error_message)
raise ValueError(error_message)
self.logger.info("Go version>=1.18.0")
self.logger.info("Go version>=1.21.0")

# Check if demofile exists
if not os.path.exists(os.path.abspath(self.demofile)):
Expand Down
11 changes: 6 additions & 5 deletions awpy/parser/go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module github.com/pnxenopoulos/csgo

go 1.18
go 1.21

require github.com/markus-wa/demoinfocs-golang/v3 v3.3.0
require github.com/markus-wa/demoinfocs-golang/v4 v4.0.0-beta.2

require (
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/golang/geo v0.0.0-20230421003525-6adc56603217 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/markus-wa/go-unassert v0.1.3 // indirect
github.com/markus-wa/gobitread v0.2.3 // indirect
github.com/markus-wa/godispatch v1.4.1 // indirect
github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1 // indirect
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7 // indirect
github.com/markus-wa/quickhull-go/v2 v2.2.0 // indirect
github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
26 changes: 16 additions & 10 deletions awpy/parser/go.sum
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/geo v0.0.0-20180826223333-635502111454/go.mod h1:vgWZ7cu0fq0KY3PpEHsocXOWJpRtkcbKemU4IUw0M60=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/geo v0.0.0-20230421003525-6adc56603217 h1:HKlyj6in2JV6wVkmQ4XmG/EIm+SCYlPZ+V4GWit7Z+I=
github.com/golang/geo v0.0.0-20230421003525-6adc56603217/go.mod h1:8wI0hitZ3a1IxZfeH3/5I97CI8i5cLGsYe7xNhQGs9U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/markus-wa/demoinfocs-golang/v3 v3.3.0 h1:cXAI081cH5tDmmyPuyUzuIGeP8strtVzdtRB5VlIvL8=
github.com/markus-wa/demoinfocs-golang/v3 v3.3.0/go.mod h1:NzAkCtDshPkoSMg3hAyojkmHE4ZgnNWCM1Vv4yCPLsI=
github.com/markus-wa/demoinfocs-golang/v4 v4.0.0-beta.2 h1:vOkS+YKVJYC/KeA+UJSrKojcj23Y8NX4Mt/DKpIVT08=
github.com/markus-wa/demoinfocs-golang/v4 v4.0.0-beta.2/go.mod h1:YuAfxa0q7mG+HSUjrSXFmaZ8xVRWK9k/vcG/rLbzrBA=
github.com/markus-wa/go-unassert v0.1.3 h1:4N2fPLUS3929Rmkv94jbWskjsLiyNT2yQpCulTFFWfM=
github.com/markus-wa/go-unassert v0.1.3/go.mod h1:/pqt7a0LRmdsRNYQ2nU3SGrXfw3bLXrvIkakY/6jpPY=
github.com/markus-wa/gobitread v0.2.3 h1:COx7dtYQ7Q+77hgUmD+O4MvOcqG7y17RP3Z7BbjRvPs=
github.com/markus-wa/gobitread v0.2.3/go.mod h1:PcWXMH4gx7o2CKslbkFkLyJB/aHW7JVRG3MRZe3PINg=
github.com/markus-wa/godispatch v1.4.1 h1:Cdff5x33ShuX3sDmUbYWejk7tOuoHErFYMhUc2h7sLc=
github.com/markus-wa/godispatch v1.4.1/go.mod h1:tk8L0yzLO4oAcFwM2sABMge0HRDJMdE8E7xm4gK/+xM=
github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1 h1:YH4WI14HARrM3C6mKUMFDBz93O25oWSlLEYGeL27G0w=
github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1/go.mod h1:JIsht5Oa9P50VnGJTvH2a6nkOqDFJbUeU1YRZYvdplw=
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7 h1:aR9pvnlnBxifXBmzidpAiq2prLSGlkhE904qnk2sCz4=
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7/go.mod h1:JIsht5Oa9P50VnGJTvH2a6nkOqDFJbUeU1YRZYvdplw=
github.com/markus-wa/quickhull-go/v2 v2.2.0 h1:rB99NLYeUHoZQ/aNRcGOGqjNBGmrOaRxdtqTnsTUPTA=
github.com/markus-wa/quickhull-go/v2 v2.2.0/go.mod h1:EuLMucfr4B+62eipXm335hOs23LTnO62W7Psn3qvU2k=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
Expand All @@ -26,14 +29,17 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0=
github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
12 changes: 9 additions & 3 deletions awpy/parser/parse_demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strconv"
"strings"

dem "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs"
common "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/common"
events "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
dem "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"
common "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common"
events "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events"
)

const unknown = "Unknown"
Expand Down Expand Up @@ -551,6 +551,12 @@ func convertRoundEndReason(r events.RoundEndReason) string {
return "TerroristsSurrender"
case events.RoundEndReasonCTSurrender:
return "CTSurrender"
case events.RoundEndReasonStillInProgress:
return "StillInProgress"
case events.RoundEndReasonTerroristsPlanted:
return "TerroristsPlanted"
case events.RoundEndReasonCTsReachedHostage:
return "CTsReachedHostage"
default:
return unknown
}
Expand Down
2 changes: 1 addition & 1 deletion awpy/parser/parse_demo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"testing"

common "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/common"
common "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common"
)

func TestConvertRank(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions awpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __getitem__(self, item: Any) -> Any: # noqa: ANN401
def check_go_version() -> bool:
"""Function to check the Golang version of the current machine.

Returns True if greater than 1.18.0
Returns True if greater than 1.21.0

Returns:
bool whether the found go version is recent enough
Expand All @@ -64,7 +64,7 @@ def parse_go_version(parsed_resp: list[bytes] | None) -> list[str]:
except Exception as e: # noqa: BLE001
print(e)
return False
return [int(x) for x in parsed_go_version] >= [1, 18]
return [int(x) for x in parsed_go_version] >= [1, 21]


def is_in_range(value: float, minimum: float, maximum: float) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Installation

``pip install awpy``

To install awpy, you must have Python >= 3.11 and Go (the programming language) installed. You need a Go version greater than 1.18, and you can visit this link to install the latest `Golang version <https://go.dev/dl/>`_.
To install awpy, you must have Python >= 3.11 and Go (the programming language) installed. You need a Go version greater than 1.21, and you can visit this link to install the latest `Golang version <https://go.dev/dl/>`_.

Once you have Golang installed, you can check your version in command line by using the command ``go version``. After this, simply run ``pip install awpy``.
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class TestUtils:

@patch("awpy.utils.subprocess")
def test_go_version(self, mock_subproc: MagicMock):
"""Tests if the Golang version >= 1.18.0."""
"""Tests if the Golang version >= 1.21.0."""
inputs = [
b"go version go1.18.4 windows/amd64",
b"go version go1.21.0 windows/amd64",
b"go version go1.17.4 windows/amd64",
b"go version go1.7.4 windows/amd64",
b"",
Expand Down