Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App naming convention and import issues #50

Open
nesnoj opened this issue May 3, 2019 · 2 comments
Open

App naming convention and import issues #50

nesnoj opened this issue May 3, 2019 · 2 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@nesnoj
Copy link
Member

nesnoj commented May 3, 2019

Hey @rl-institut/wam-team, we need to talk ;).

For historical reasons, the app repos are named WAM_APP_<NAME> which is now the (implicit) naming convention. At least in the v0.1 release's .gitignore file those dirs are excluded from version control to prevent accidental adding of app files. Contrary, the current docs say you must rename the app dir.

I'd like to discuss implications of this convention, find a consistent way to name and structure apps and derive a guideline for app developers.

Requirements of status quo:

  1. Apps are located in the WAM root dir: <WAM_ROOT>/<APP_NAME>/
  2. Directory <APP_NAME> is treated as package hence needs an __init__.py file =>
    <APP_NAME> = <PACKAGE_NAME> = <NAME_IN_WAM_APPS>
  3. Structure in app dir must follow the WAM's requirements as configuration is read from them:
    • files you must have located in your app dir: urls.py (imported here)
    • files you can use to config you app: settings.py (e.g. to add additional INSTALLED_APPS, imported here), app_settings.py (imported here and here)

As a straightforward solution for WAM_APP_stemp_abw I tried to keep the Repo name, change the name in env WAM_APPS accordingly and add an init file with

import WAM_APP_stemp_abw as stemp_abw

to keep my custom app name. This and other attempts didn't work out as Python always uses the dir name as package name (ref) (any hints welcome).

So currently it seems to be impossible to use a custom package structure or app name - only with renaming dir since it has to match the app package name.
I see two options here:

  1. Keep it as it is -> implications:
    • rename all existing apps which do not match the naming convention
    • to create a distributable app you would have to keep a second folder structure for your app with (example tutorial).
    • bulky import statements like from WAM_APP_my_super_package.XXX.YYY import ZZZ
    • WAM "branding" of packages (ugly)

Does this option really suit the future needs?
2. Refactor app structure (see below)

New requirements:

  1. App directories in WAM are named WAM_APP_<NAME>
  2. Allow apps to use a custom name different from WAM_APP_<NAME>. This allows for module imports à la from myapp.XXX import YYY.
    It could be achieved using a (in python quite common package) structure like
<WAM_ROOT>/
  WAM_APP_myapp/
    myapp/  # (contains app)
    doc/
    __init__.py
    setup.py
    ...
  WAM_APP_yourapp/
    ...
  __init__.py
  doc/
  static/
  ...

using a variable APP_NAME = 'myapp' in WAM_APP_myapp/__init__.py which is used by WAM core to properly load urls.py etc. from package.
3. Allow developers to create a package from their app (should work with the above structure).

For the 2nd options, there'd be some tasks around the corner @henhuy.. ;)

Opinions, hints, amendments?

@nesnoj nesnoj added help wanted Extra attention is needed question Further information is requested labels May 3, 2019
@Bachibouzouk
Copy link
Contributor

Thanks for starting the conversation @nesnoj ! I need to do a bit of reading before I jump in the discussion :)

@christian-rli
Copy link
Contributor

Thanks for bringing this up @nesnoj . I would like to discuss this as a group on Tuesday. I'm going to send out invitations to you.

@nesnoj nesnoj added this to the WAM-App integration milestone Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants