Nori Jacoby
Nori Jacoby

Reputation: 51

In psynet, if I use the "newenv" approach, how can I change the psynet code?

I want to use the "newenv" approach, but now I need to make changes to psynet (for example adding a log line or rpdb.set_trace()), where is this local copy? And can I simply change it or I need to reinstall the environment with reenv?

Upvotes: 1

Views: 66

Answers (3)

joanis
joanis

Reputation: 12270

The simplest way to do this is certainly to edit the file in the venv, but as has been pointed out it's easy to lose track of that change and overwrite it. I do that anyway if it's a short term test.

However, my preferred approach when I want to modify a library like this is to clone its source code from Git, do the modifications in my cloned sandbox, and do a pip install -e . inside the module after having activated the venv. That will make this venv replace the previously installed version of the library with my sandbox version of it.

Upvotes: 1

Peter Harrison
Peter Harrison

Reputation: 912

If you want to achieve this, you should edit the source code files within your env directory, which will be located in your project directory. PsyNet will be located somewhere like this:

env/lib/python3.9/site-packages/psynet

Note that any changes will be reset the next time you run newenv.

Upvotes: 1

Manuel Anglada Tort
Manuel Anglada Tort

Reputation: 96

I believe this is the right workflow:

  1. In a new project, start by creating a new environment, with the command newenv, which currently stands for
alias newenv="python3 -m venv env && source env/bin/activate && pip install -r constraints.txt"

This will install all the dependencies in your constraints file, which should include the Psynet version too.

  1. If you make any changes in the code (e.g., experiment.py) that do not involve any change in your dependencies/ packaged, then you do not need to do anything. But if your changes involve the packages your are working with in your environment (a change in PsyNet or some of your working packages, like REPP or melody-experiments), then you will need to first push the changes in GITHUB and then reinstall your working environment, using the command reenv, which stands for:
alias reenv="rm -rf env && newenv && source env/bin/activate && pip install -r constraints.txt"
  1. There are other situations in which one only wants to make a change in requirements.txt, such as adding a new package or changing PsyNet's version. In this case, after changing your requirements, you should run dallinger generate-constraints, which will update your constraints.txt accordingly Then, run reenv.

Upvotes: 1

Related Questions