Skip to content

Commit

Permalink
Fix requirements.txt and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaxter committed Aug 16, 2023
1 parent 7acb846 commit 0191c30
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,24 @@ The markdown files in this repo are the source of truth for the content in our d

### Community Notes open-source code

The algorithm that powers Community Notes can be found on the [sourcecode folder](https://github.com/twitter/communitynotes/tree/main/sourcecode), and instructions on how to use it can be found in the [Guide](https://twitter.github.io/communitynotes/note-ranking-code/).
The algorithm that powers Community Notes can be found in the [sourcecode folder](https://github.com/twitter/communitynotes/tree/main/sourcecode), and instructions on how to use it can be found in the [Guide](https://twitter.github.io/communitynotes/note-ranking-code/).

While your normal Python install may "just work" if you're lucky, if you run into any issues and want to install the exact versions of Python packages that we've tested the code with, please create a new virtual environment and install the packages from requirements.txt:

```
$ python -m venv communitynotes_env
$ source communitynotes_env/bin/activate
$ pip install -r requirements.txt
```

Then after downloading the data files (see next section) into /sourcecode/, you will be able to run:

```
$ cd sourcecode
$ python main.py
```

Most versions of Python3 should work, but we have tested the code with Python 3.7.9.

### Community Notes data

Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
numpy==1.21.6
pandas==1.3.5
matplotlib==3.5.2
numpy==1.19.2
pandas==1.1.5
tensorflow==2.5.0

torch==1.12.0
matplotlib==3.5.2

2 comments on commit 0191c30

@elvey
Copy link

@elvey elvey commented on 0191c30 Aug 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this did not help.

It (the virtual environment) resulted in the errors below* when I tried pip install -r requirements.txt on M1.

On the other hand, I did have success, without it; see my comment on #111.

*errors:

Collecting numpy==1.19.2 (from -r requirements.txt (line 1))
  Downloading numpy-1.19.2.zip (7.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.3/7.3 MB 9.3 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [58 lines of output]
      Running from numpy source directory.
      setup.py:470: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
        run_build = parse_setuppy_commands()
      warning: _philox.pyx:19:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  self.rng_state.ctr.v[i] = counter[i]
      
              self._reset_state_variables()
      
              self._bitgen.state = <void *>&self.rng_state
              self._bitgen.next_uint64 = &philox_uint64
                                         ^
      ------------------------------------------------------------
      
      _philox.pyx:195:35: Cannot assign type 'uint64_t (*)(void *) except? -1 nogil' to 'uint64_t (*)(void *) noexcept nogil'
      Processing numpy/random/_bounded_integers.pxd.in
[...]

@elvey
Copy link

@elvey elvey commented on 0191c30 Aug 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! Of course my attempt to use the venv didn't work - it was still trying to install numpy 1.19, which isn't possible on M1. So maybe don't go back to it, as 1.21.6 and 1.24.3 seem to work?

WFM:
matplotlib 3.7.2
numpy 1.24.3
pandas 2.0.3
torch 2.0.1

tensorflow wasn't needed.

Please sign in to comment.