Codeforces API Utilities
Python wrappers for the Codeforces API, and support for generating an ICPC Tools event feed.
Installation
To install the package, first clone it and then install using pip
:
pip install .
It is recommended to use a Virtual environment.
Optional: If you wish to run authorized API calls, copy example.env
to .env
and set the API parameters in it.
Check CF API docs to see how to generate an API key.
Tool: ICPC Standings Resolver
Go to tools.icpc.global and download “Resolver”. Optionally you can download “Contest Utilities” to validate the generated files.
In Resolver, you should have the executables resolver.sh
and awards.sh
In Contest Utilites, you should have the executable eventFeed.sh
(others are not needed).
A basic CLI tool is provided: examples/feed.py. This tool can be used to generate a JSON event feed for the ICPC resolver tool.
Run
python examples/feed.py <status_output_file.json> <standings_output_file.json> <feed.json>
.cd
to the resolver tool, and run./resolver.sh /path/to/feed.json
(optional) To validate, run
/path/to/eventFeed.sh --validate feed.json
.(optional) To edit the awards manually,
cd
to the resolver folder and runawards.sh
. Select “Disk” and load the generatedfeed.json
file.
Contributing
Install the project in development mode:
pip install -e .[dev]
The CI checks can be run with make ci
.
ICPC EventFeed dataclass
To generate/update the dataclasses for ICPCTools event feeds, first clone the ccs-specs
submodule:
git submodule init
git submodule update
Now run datamodel-codegen
to generate dataclasses from the JSONSchema:
datamodel-codegen \
--input "ccs-specs/json-schema/event-feed-array.json" \
--input-file-type jsonschema \
--output cfutils/icpctools/event_feed.py \
--output-model-type dataclasses.dataclass \
--target-python-version 3.11 \
--use-standard-collections \
--use-schema-description