Organisation of small projects (e.g. lambdas)

Answered

I'm just looking for a bit of advice as to what PyCharm can offer regarding working with small projects.  In particular, wokring with the Python path.

So we have a couple of projects that contain a number of AWS lambdas.  These have been laid out in a couple of different ways:

First way:

src/
    lambdas/
       lambda1/
            code/
                <python files>
               requirementst.xt (referring to library code using relative paths)
            tests/
            infrastructure.yaml         

      libraries/
          sharedlibrary1/
             code/
                setup.py etc.

 

The other way:

infrastructure/
    lambda1.yaml
lambdas/
    lambda1/
      <python flies>
      <symlinks to shared code elsewhere>
tests/
    lambda1/

In both cases, we tend to open up PyCharm at the root and work on it as a whole.  The first method allows me to open up each lambda as a seprate project, but it always feel more convenient to open up the whole thing and see everything together.   (And avoids having a Recently Used List containing loads of small projects)

The problem comes with the python path.  In order to get proper code assistance or run unit tests, I need to keep marking/unmarking directories as source etc.  What normally happens if we end up just doing without coding assistance a lot of the time, unless there are big changes in which case we might fiddle with it.  But quite often we're navigating across the whole thing to try to track down problems, so it's not really practical to keep switching contexts.

Is there anything in PyCharm where we can define some sort of scope, so that if I'm editing code in one directory it might use one set of Source Directories, but if I'm somewhere else it automatically changes?

Does anyone else have any experience with this kind of thing?

2 comments

Hi John,

So how many projects do you work on?

I believe you could just attach projects to each other. PyCharm will then add Project Dependencies to your settings where you can manage which project depends on which. Imports will then resolve and you can enhance it with marking needed directories as Sources (or just use the whole path to modules).

See https://www.jetbrains.com/help/pycharm/project-dependencies.html and https://www.jetbrains.com/help/pycharm/opening-multiple-projects.html

0

Thanks for the reply - sorry for taking so long to get back to it.   We have about a dozen projects with 6 or 7 libraries that they use.

Your suggestion isn't quite what I was after, but it might provide a solution that works just as well.  I need a bit of time to play with it.  Ideally what I was hoping for was one big selection with everything in it, with the source folders effectively changing as I navigate about.  But I suppose if I open up the lambda I'm interested in as a project and move in libraries that might be a good alternative.

Your help is much appreciated - thank you

0

Please sign in to leave a comment.