Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
N
nlp_ws
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Redmine
    • Redmine
  • Merge Requests 1
    • Merge Requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • nlpworkers
  • nlp_ws
  • Issues
  • #3

Closed
Open
Created May 20, 2022 by Mateusz Gniewkowski@MGniewOwner

Add environment variables support

First read wiki try to run an (example)[https://gitlab.clarin-pl.eu/nlpworkers/tester] (play around with example/worker.py).

All the configuration is taken from the config.ini file -- the nlp_ws library should also support env variables.

  1. The enviromental variables should always override values in config.ini (if they are defined)
  2. Enviromental variables should always be written with capital letters (THIS_IS_AN_EXAMPLE).
  3. This is not a requirement for keywords in config.ini, so you should convert envs to small letters programically
  4. Before implementing your own solution please google for some standard approach (I think that the config loading function should be overrided or extended) -> nlp_ws/_service.py:128
  5. Please mind variables from lines 90-110 (like CFG_S_SERV). They contain possible keywords from config.ini files.
  6. It is bizzare that variables given below (ad. 5) are not named accordingly. Consider changing that (eq "CFG_S_SERV_O_RHOST" -> "CFG_S_SERV_O_RABBIT_HOST"). If its done, we have a ready convenction for naming enviroment variables!
    CFG_S_SERV = 'service'
    CFG_S_SERV_O_ROOT = 'root'
    CFG_S_SERV_O_TOOL = 'tool'
    CFG_S_SERV_O_QPREFIX = 'queue_prefix'
    CFG_S_SERV_O_RHOST = 'rabbit_host'
    CFG_S_SERV_O_RUSER = 'rabbit_user'
    CFG_S_SERV_O_RPSWD = 'rabbit_password'
    CFG_S_SERV_O_PROD = 'is_production'

    CFG_S_TOOL = 'tool'
    CFG_S_TOOL_O_NUMW = 'workers_number'

    CFG_S_LOG = 'logging'
    CFG_S_LOG_O_PORT = 'port'
    CFG_S_LOG_O_FILENAME = 'logfile_name'
    CFG_S_LOG_O_FILESIZE = 'logfile_maxsize'
    CFG_S_LOG_O_FILECOUNT = 'logfile_maxbackups'
    CFG_S_LOG_O_FORMAT = 'log_format'
    CFG_S_LOG_O_LEVEL = 'local_log_level'

    CFG_S_LOGLEVELS = 'logging_levels'
  1. If point 6. is met a programmer (that creates some nlp_worker) could either define some extra parameters using config.ini:
[tool]
my_awsome_variable = "value"

or by passing env like that

CFG_S_TOOL_O_MY_AWSOME_VARIABLE=value

This of course would require you to read all envs that starts with CFG_S_TOOL, CFG_S_SERV and CFG_S_LOG and add them to config (this require some string operation, as the variable should be visible as my_awsome_variable).

  1. Do not break compability! Under no circumstances ;)
  2. If something is not clear, or you have your own thoughts on the problem, please talk to me.
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None