Skip to content

Commit

Permalink
[JIRA:LICO-7126] Add endpoint to retrieve billing group information f…
Browse files Browse the repository at this point in the history
…or each user
  • Loading branch information
hrusan authored and wangyt38 committed Jul 20, 2023
1 parent 9ac65e9 commit c9f36e7
Show file tree
Hide file tree
Showing 42 changed files with 105 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ target/

# generate by setuptools_scm
_version.py

# Temporary files
.*.swp
32 changes: 32 additions & 0 deletions core/apps/accounting/lico/core/accounting/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2015-2023 Lenovo
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


from rest_framework import serializers

from .models import BillGroup, UserBillGroupMapping


class BillGroupSerializer(serializers.ModelSerializer):
class Meta:
model = BillGroup
fields = ('id', 'name', 'balance')


class UserBillGroupSerializer(serializers.ModelSerializer):
bill_group = BillGroupSerializer()

class Meta:
model = UserBillGroupMapping
fields = ('id', 'username', 'bill_group')
23 changes: 23 additions & 0 deletions core/apps/accounting/lico/core/accounting/views/user_billgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import logging

from django.db import IntegrityError, transaction
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView as BaseAPIView

Expand All @@ -28,6 +29,8 @@
from lico.core.contrib.schema import json_schema_validate
from lico.core.contrib.views import APIView, InternalAPIView

from ..serializers import UserBillGroupSerializer

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -87,6 +90,26 @@ def put(self, request):
class UserBillGroupView(BaseUserBillGroupView, APIView):
permission_classes = (AsAdminRole,)

@AsUserRole
def get(self, request):
try:
ubg_mapping = UserBillGroupMapping.objects.get(
username=self.request.user.username
)
return Response(
UserBillGroupSerializer(ubg_mapping).data,
status=status.HTTP_200_OK
)
except UserBillGroupMapping.DoesNotExist:
# user does not belong to any billing group
return Response(
{
'username': self.request.user.username,
'bill_group': None,
},
status=status.HTTP_200_OK
)

@AsUserRole
@json_schema_validate({
"type": "object",
Expand Down
8 changes: 8 additions & 0 deletions core/apps/template/lico/core/template/views/user_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import base64
import imghdr
import json
import logging
import os
import tempfile
Expand Down Expand Up @@ -215,6 +216,13 @@ def validate_job_template_params( # noqa:C901
data['logo'] = 'data:image/jpeg;base64,' \
+ base64.b64encode(f.read()).decode()
os.remove(tmp_img_file)

# set default run time if no value was provided
params = json.loads(data["parameters_json"])
for p in params:
if p["id"] == "run_time" and not p["defaultValue"]:
p["defaultValue"] = settings.TEMPLATE.DEFAULT_RUN_TIME
data["parameters_json"] = json.dumps(params)
return data


Expand Down
2 changes: 2 additions & 0 deletions core/etc/lico.ini.d/template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ MODULE_PATH = "/opt/ohpc/pub/modulefiles"

NOTIFY_RESTAPI_TIMEOUT = 30
STATEFUL_TIMEOUT = 300

DEFAULT_RUN_TIME = "24h"
2 changes: 1 addition & 1 deletion core/templates/ai_caffe/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_chainer/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_intel_caffe/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_mxnet/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_neon/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_nvidia_tensorrt/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_paddlepaddle/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_pytorch/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_scikit/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_tensorflow/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/ai_tensorflow2/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/charliecloud/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/charliecloud_mpi/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/common/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/comsol/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/jupyter/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/linpack_hpl/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/mpi/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_intel_gdb/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_intel_modin/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_intel_modin_multi/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_intel_mpi/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
}
]
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_intel_python/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_intel_pytorch/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_intel_tensorflow2/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_intel_vtune_profiler/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
2 changes: 1 addition & 1 deletion core/templates/oneapi_mpitune/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"en": "Please input run time limit for the job,Format is 'Xd Xh Xm',which 'Xd' represents X days,'Xh' represents X hours and 'Xm' represents X minutes.",
"zh": "请输入job的运行时间限制,格式为“Xd Xh Xm”,“Xd”表示X天,“Xh”表示X小时,“Xm”表示X分钟。"
},
"defaultValue": "24h",
"defaultValue": "",
"must": false
},
{
Expand Down
Loading

0 comments on commit c9f36e7

Please sign in to comment.