0

In brief Opening a PyCharm project takes long time due to index/cache build process - to speed it up, I'm looking for how to call PyCharm to build that via a command line.

This question is also posted as PyCharm ticket here

In details PyCharm index build takes long time to finish which is quite annoying when start working with project.

enter image description here

I want that run to be executed via command line so that I can run them at night e.g. 03:00 AM. That will help us to open the project quickly since the cache/index has been prepared by our scheduled command-line above.

So the question is, what is the command to do so? My google search on this topic and on our site is empty so I asked here.

p.s.

We can open a PyCharm project via command line as discussed here; though I cannot find an option for building index/cache.

$ charm --help
Usage:
  /usr/local/bin/charm -h | -? | --help
  /usr/local/bin/charm [project_dir]
  /usr/local/bin/charm [-l|--line line] [project_dir|--temp-project] file[:line]
  /usr/local/bin/charm diff <left> <right>
  /usr/local/bin/charm merge <local> <remote> [base] <merged>
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
  • Are you just asking how to run a batch file at a scheduled interval? Or how to open PyCharm at a specific time? – Mars Nov 05 '18 at 04:05
  • @Mars I'm asking what is the command line to run the index/cache build – Nam G VU Nov 05 '18 at 04:10
  • There no such ability and it is not planned to be done – user2235698 Nov 13 '18 at 18:36
  • Base on which source do we have your conclusion @user2235698? – Nam G VU Nov 13 '18 at 22:33
  • @Nam G VU I'm a member of PyCharm team – user2235698 Nov 17 '18 at 20:22
  • Oh, then can we know the reason why no plan for that? – Nam G VU Nov 18 '18 at 02:23
  • @Nam G VU I suppose because it is requested really rare. The longest indexing runs after project has been opened for the first time. On the next runs it just reindexes changed files. – user2235698 Nov 19 '18 at 16:08
  • @user2235698 Thanks for the explaination; though, that loading index/cache keep re-run very often beside the 1st time. One sample, a team project will have their code/git-branch merged very often in half-daily time. – Nam G VU Nov 20 '18 at 03:47
  • @user2235698 My workaround for the moment is as below https://stackoverflow.com/a/53379691/248616. It would be very nice if you and the JetBrains team look at this case. Please don't tell us developer which is the right feature to ask since when we asked, we thought about it - I did think about this in months before I asked in the public. – Nam G VU Nov 20 '18 at 03:55
  • 1
    @user2235698 For requests or bug reports it's better to use our [issue](https://youtrack.jetbrains.com/issues/PY) tracker. At least your suggestion won't be forgotten forever on StackOverflow. Also somebody could vote or comment your report with his suggestions or something like this. – user2235698 Nov 20 '18 at 16:08
  • @user2235698 OK. Though I think stackoverflow is more crowded and active. Thanks again for your time. – Nam G VU Nov 20 '18 at 16:46
  • @user2235698 Posted on your issue tracker as suggested https://youtrack.jetbrains.com/issue/PY-32775 – Nam G VU Nov 20 '18 at 17:41

2 Answers2

0

This is the workaround for now on my Ubuntu Desktop 16.04

Please make sure charm command is installed on your system to call reload_pycharm_projects bash command as defined below.

function reload_pycharm_projects() {
  cd $path_to_code_home
    echo 'Running PyCharm...'
    charm &
    sleep 16 # wait 16s for PyCharm window to be opened; put in the time suitable on your machine

    # open pycharm projects - list all projects of your interest below
    echo 'Loading projects...'
    charm p1
    charm p2  
    charm p3  
    sleep 90 # wait 90s for all project load & index/cache refreshed; put in more time as you want
  cd --

  echo 'Closing Pycharm...'
  kill -9 $(ps x | grep -E .+java.+PyCharm | awk '{print $1}') # kill pycharm window
  exit
}
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
0

In 2020 Jetbrains added shared indexes to the IDE(s), which fit the use case: there is a dedicated CLI tool which can build shared index, and the editor can be set up to automatically retrieve shared index from a central server.

Masklinn
  • 34,759
  • 3
  • 38
  • 57