jupyterhub / systemdspawner

Spawn JupyterHub single-user notebook servers with systemd
BSD 3-Clause "New" or "Revised" License
92 stars 45 forks source link

Add new option `cpu_weight` and user- and group-specific configurations #98

Closed ticoneva closed 10 months ago

ticoneva commented 2 years ago

This PR introduces two changes:

  1. New configuration option cpu_weight. This sets the systemd property CPUWeight, which causes available CPU time to be sliced in proportion to each process' weight.
  2. Introduces two new configuration options group_config and user_config. These two options accept dict of configuration options specific to individual groups and individual users. For example, for group_config:
      c.SystemdSpawner.group_config = {
         'group_name': {
               'property': value,
               ...
         },
         ...
      }

    Only configurations implemented within systemdspawnwer are supported.

The combination of change 1. and 2. allow group- or user-specific resource allocation. For example, on our academic computing cluster, faculty members have much higher cpu_weight and mem_limit than students.

welcome[bot] commented 2 years ago

Thanks for submitting your first pull request! You are awesome! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly. welcome You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

consideRatio commented 1 year ago

This PR includes two kinds of features (user/group config and cpu weight), and I think both are relevant.

If you want to work this still @ticoneva, I'd be happy to invest time reviewing it!

ticoneva commented 1 year ago

@consideRatio I have been thinking about the issue of maintainable too. This is what I have come up with at this moment:

from traitlets.traitlets import is_trait
...
def overwrite_config(self,source):
    for config_name in source:
        config = getattr(self,config_name)
        assert is_trait(config), f"{config_name} is not configurable."
        setattr(self,config_name,source[config_name])

This should cover all configurable options, since as far as I I tell all spawner configurations are handled through traitlets.

Regarding overwrite vs merge, from what I can see in kubespawner, the current implement appears to be a overwrite rather than a merge?

Splitting the two features into separate PRs is not a problem, I can do that.