Skip to content

Commit

Permalink
Use string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
etejedor committed Dec 19, 2023
1 parent 62e52cd commit 8b7037b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions swan-cern/files/swan_computing_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def _init_hadoop_secret(self):
return None

username = self.spawner.user.name
hadoop_secret_name ='hadoop-tokens-%s' % username
hadoop_secret_name = f'hadoop-tokens-{username}'

webhdfs_token_base64 = ''
k8suser_config_base64 = ''
Expand Down Expand Up @@ -120,7 +120,7 @@ async def _init_hadoop_secret(self):
else:
await self.spawner.api.create_namespaced_secret(swan_container_namespace, secret_data)
except ApiException as e:
raise Exception("Could not create required hadoop secret: %s\n" % e)
raise Exception(f'Could not create required hadoop secret: {e}\n')

return hadoop_secret_name

Expand Down Expand Up @@ -299,7 +299,7 @@ async def _open_ports(self, num_ports):
computing resources.
"""

computing_ports_service = "computing-ports-" + self.spawner.user.name
computing_ports_service = f'computing-ports-{self.spawner.user.name}'
notebook_container = self._get_pod_container('notebook')

try:
Expand All @@ -308,7 +308,7 @@ async def _open_ports(self, num_ports):
for port_id in range(1, num_ports + 1):
service_template_ports.append(
V1ServicePort(
name="comp-port-" + str(port_id),
name=f'comp-port-{str(port_id)}',
port=port_id
)
)
Expand All @@ -334,7 +334,7 @@ async def _open_ports(self, num_ports):
try:
service = await self.spawner.api.create_namespaced_service(swan_container_namespace, service_template)
except ApiException as e:
raise Exception("Could not create service that allocates random ports for computing integrations: %s\n" % e)
raise Exception(f'Could not create service that allocates random ports for computing integrations: {e}\n')

# Replace the service with allocated nodeports to map nodeport:targetport
# and set these ports for the notebook container
Expand Down Expand Up @@ -373,7 +373,7 @@ async def _open_ports(self, num_ports):
)
)
except ApiException as e:
raise Exception("Could not create required user ports: %s\n" % e)
raise Exception(f'Could not create required user ports: {e}\n')


def computing_modify_pod_hook(spawner, pod):
Expand Down

0 comments on commit 8b7037b

Please sign in to comment.