fix:add Http Api for model ,Algorithms,Dataset

This commit is contained in:
qiwang 2025-01-16 11:04:17 +08:00
parent f9bb9d5638
commit 2f055e2446
15 changed files with 611 additions and 7 deletions

17
go.mod
View File

@ -7,6 +7,7 @@ toolchain go1.22.4
require (
github.com/JCCE-nudt/apigw-go-sdk v0.0.0-20230525025609-34159d6f2818
github.com/docker/docker v24.0.7+incompatible
github.com/gin-gonic/gin v1.10.0
github.com/go-resty/resty/v2 v2.15.3
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.61
github.com/robfig/cron/v3 v3.0.1
@ -22,8 +23,12 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@ -34,12 +39,18 @@ require (
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
@ -53,6 +64,8 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
@ -72,6 +85,8 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/redis/go-redis/v9 v9.6.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.etcd.io/etcd/api/v3 v3.5.16 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.16 // indirect
@ -90,6 +105,8 @@ require (
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect

43
go.sum
View File

@ -18,12 +18,20 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
@ -52,6 +60,12 @@ github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@ -63,6 +77,14 @@ github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-resty/resty/v2 v2.15.3 h1:bqff+hcqAflpiF591hhJzNdkRsFhlB96CYfBwSFvql8=
github.com/go-resty/resty/v2 v2.15.3/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
@ -71,6 +93,8 @@ github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqw
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
@ -126,12 +150,18 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
@ -195,12 +225,18 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
@ -254,6 +290,9 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@ -261,6 +300,8 @@ golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@ -414,6 +455,8 @@ k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 h1:1dWzkmJrrprYvjGwh9kEUx
k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38/go.mod h1:coRQXBK9NxO98XUv3ZD6AK3xzHCxV6+b7lrquKwaKzA=
k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 h1:b2FmK8YH+QEwq/Sy2uAEhmqL5nPfGYbJOcaqjeYYZoA=
k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=

View File

@ -14,3 +14,6 @@ type Config struct {
CoreUrl string
FileUrl string
}
type Configuration struct {
}

View File

@ -2,7 +2,6 @@ package config
type ModelArtsConf struct {
CloudBrain2 Conf `json:"CloudBrain2"`
Njaci Conf `json:"Njaci"`
JobLogsPath string `json:"JobLogsPath"`
Platform string `json:"Platform"`
}

View File

@ -0,0 +1,112 @@
package httpmodelarts
type CreateAlgorithmsReq struct {
Metadata Metadata `json:"metadata"`
JobConfig JobConfig `json:"jobConfig"`
ResourceRequirements []ResourceRequirements `json:"resourceRequirements"`
AdvancedConfig AdvancedConfig `json:"advancedConfig"`
}
type CreateAlgorithmsResp struct {
Metadata Metadata `json:"metadata"`
JobConfig JobConfig `json:"jobConfig"`
ResourceRequirements []ResourceRequirements `json:"resourceRequirements"`
AdvancedConfig AdvancedConfig `json:"advancedConfig"`
}
type Metadata struct {
Name string `json:"name"`
Description string `json:"description"`
WorkspaceId string `json:"workspaceId"`
//AiProject string `json:"ai_project ,omitempty"`
Tags string `json:"tags ,omitempty"`
}
type JobConfig struct {
CodeDir string `json:"codeDir"`
BootFile string `json:"bootFile"`
Command string `json:"command"`
Parameters []Parameters `json:"parameters"`
ParametersCustomization bool `json:"parametersCustomization"`
Inputs []Inputs `json:"inputs"`
Outputs []Outputs `json:"outputs"`
Engine Engine `json:"engine"`
}
type Parameters struct {
Name string `json:"name"`
Description string `json:"description"`
I18nDescription string `json:"i18nDescription"`
Value string `json:"value"`
Constraint Constraint `json:"constraint"`
}
type Inputs struct {
Name string `json:"name"`
Description string `json:"description"`
RemoteConstraints string `json:"remoteConstraints"`
}
type Outputs struct {
Name string `json:"name"`
Description string `json:"description"`
}
type Engine struct {
EngineId string `json:"engineId"`
EngineName string `json:"engineName"`
EngineVersion string `json:"engineVersion"`
ImageUrl string `json:"imageUrl"`
}
type Constraint struct {
Type string `json:"type"`
Editable string `json:"editable"`
Required string `json:"required"`
Sensitive string `json:"sensitive"`
ValidType string `json:"validType"`
ValidRange []string `json:"validRange"`
}
type ResourceRequirements struct {
/*Key string `json:"key ,omitempty"`
Value string `json:"value ,omitempty"`
Operator string `json:"operator ,omitempty"`*/
}
type AdvancedConfig struct {
//AutoSearch AutoSearch `json:"auto_search ,omitempty"`
}
type AutoSearch struct {
SkipSearchParams string `json:"skipSearchParams"`
RewardAttrs []RewardAttrs `json:"rewardAttrs"`
SearchParams []SearchParams `json:"searchParams"`
AlgoConfigs []AlgoConfigs `json:"algoConfigs"`
}
type RewardAttrs struct {
Name string `json:"name"`
Mode string `json:"mode"`
Regex string `json:"regex"`
}
type SearchParams struct {
Name string `json:"name"`
ParamType string `json:"paramType"`
LowerBound string `json:"lowerBound"`
UpperBound string `json:"upperBound"`
DiscretePointsNum string `json:"discretePointsNum"`
DiscreteValues []string `json:"discreteValues"`
}
type AlgoConfigs struct {
Name string `json:"name"`
Params []AutoSearchAlgoConfigParameter `json:"params"`
}
type AutoSearchAlgoConfigParameter struct {
Key string `json:"key"`
Value string `json:"value"`
Type string `json:"type"`
}

View File

@ -0,0 +1,62 @@
package httpmodelarts
import (
"bytes"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/model"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"net/http"
)
func CreateAlgorithms(ctx *gin.Context) {
var param CreateAlgorithmsReq
var createAlgorithmsResp CreateAlgorithmsResp
if err := ctx.BindJSON(&param); err != nil {
model.Response(ctx, http.StatusBadRequest, "invalid request params", err)
return
}
platform, _ := util.GetModelArtsConfWithPlatform("modelarts-CloudBrain2")
reqByte, _ := json.Marshal(param)
// 解析JSON字符串为map[string]interface{}
var originalMap map[string]interface{}
err := json.Unmarshal(reqByte, &originalMap)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
return
}
// 转换键名
convertedMap := convertKeys(originalMap)
// 将转换后的map序列化为JSON字符串
convertedJson, err := json.MarshalIndent(convertedMap, "", " ")
body, err := util.SendRequestHttp("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/algorithms",
bytes.NewBuffer(convertedJson), "modelarts-CloudBrain2")
if err != nil {
model.Response(ctx, 500, "failed to invoke", err)
return
}
var originalcamelCaseMap map[string]interface{}
error := json.Unmarshal(body, &originalcamelCaseMap)
if error != nil {
fmt.Println("Error unmarshalling JSON:", err)
return
}
// 转换键名
convertedcamelCaseMap := convertCamelCaseKeys(originalcamelCaseMap)
// 将转换后的map序列化为JSON字符串
convertedCamelCaseJson, err1 := json.MarshalIndent(convertedcamelCaseMap, "", " ")
if err1 != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
json.Unmarshal(convertedCamelCaseJson, &createAlgorithmsResp)
model.Response(ctx, http.StatusOK, "success", createAlgorithmsResp)
}

View File

@ -0,0 +1,30 @@
package httpmodelarts
type CreateDatasetReq struct {
WorkspaceId string `json:"workspaceId"`
Description string `json:"description"`
DatasetFormat int64 `json:"datasetFormat"`
WorkPath string `json:"workPath"`
WorkPathType int64 `json:"workPathType"`
DataSources []DataSources `json:"dataSources"`
ImportConfig ImportConfig `json:"importConfig"`
DataType int64 `json:"dataType"`
ImportType int64 `json:"importType"`
DatasetName string `json:"datasetName"`
}
type CreateDatasetResp struct {
DatasetId string `json:"datasetId"`
ImportTaskId string `json:"importTaskId"`
}
type DataSources struct {
DataType int64 `json:"dataType"`
DataPath string `json:"dataPath"`
}
type ImportConfig struct {
ImportPath string `json:"importPath"`
ImportType string `json:"importType"`
ImportAnnotations bool `json:"importAnnotations"`
}

View File

@ -0,0 +1,58 @@
package httpmodelarts
import (
"bytes"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/model"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"net/http"
)
func CreateDataset(ctx *gin.Context) {
var param CreateDatasetReq
var createDatasetResp CreateDatasetResp
if err := ctx.BindJSON(&param); err != nil {
model.Response(ctx, http.StatusBadRequest, "invalid request params", err)
return
}
platform, _ := util.GetModelArtsConfWithPlatform("modelarts-CloudBrain2")
reqByte, _ := json.Marshal(param)
// 解析JSON字符串为map[string]interface{}
var originalMap map[string]interface{}
err := json.Unmarshal(reqByte, &originalMap)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
return
}
// 转换键名
convertedMap := convertKeys(originalMap)
// 将转换后的map序列化为JSON字符串
convertedJson, err := json.MarshalIndent(convertedMap, "", " ")
body, err := util.SendRequestHttp("POST", platform.Endpoint+"v2/"+platform.ProjectId+"/datasets",
bytes.NewBuffer(convertedJson), "modelarts-CloudBrain2")
if err != nil {
model.Response(ctx, 500, "failed to invoke", err)
return
}
var originalcamelCaseMap map[string]interface{}
error := json.Unmarshal(body, &originalcamelCaseMap)
if error != nil {
fmt.Println("Error unmarshalling JSON:", err)
return
}
// 转换键名
convertedcamelCaseMap := convertCamelCaseKeys(originalcamelCaseMap)
// 将转换后的map序列化为JSON字符串
convertedCamelCaseJson, err1 := json.MarshalIndent(convertedcamelCaseMap, "", " ")
if err1 != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
json.Unmarshal(convertedCamelCaseJson, &createDatasetResp)
model.Response(ctx, http.StatusOK, "success", createDatasetResp)
}

View File

@ -0,0 +1,52 @@
package httpmodelarts
type CreateModelReq struct {
ModelVersion string `json:"modelVersion,omitempty"`
SourceLocation string `json:"sourceLocation,omitempty"`
ModelType string `json:"modelType,omitempty"`
ModelName string `json:"modelName,omitempty"`
SourceJobId string `json:"sourceJobId,omitempty"`
SourceJobVersion string `json:"sourceJobVersion,omitempty"`
Runtime string `json:"runtime,omitempty"`
WorkspaceId string `json:"workspaceId,omitempty"`
Description string `json:"description,omitempty"`
ExecutionCode string `json:"executionCode,omitempty"`
Dependencies []ModelDependencies `json:"dependencies,omitempty"`
Labels []string `json:"labels,omitempty"`
InstallType []string `json:"installType,omitempty"`
ModelDocs []string `json:"modelDocs,omitempty"`
Prebuild bool `json:"prebuild,omitempty"`
Cmd string `json:"cmd,omitempty"`
InitialConfig string `json:"initialConfig,omitempty"`
DynamicLoadMode string `json:"dynamicLoadMode,omitempty"`
GuideDoc GuideDoc `json:"guideDoc,omitempty"`
Template []Template `json:"template,omitempty"`
}
type ModelDependencies struct {
Installer string `json:"installer,omitempty"`
Packages Packages `json:"packages,omitempty"`
}
type Packages struct {
PackageName string `json:"package_name,omitempty"`
}
type GuideDoc struct {
DocUrl string `json:"docUrl,omitempty"`
DocName string `json:"docName,omitempty"`
}
type Template struct {
TemplateInputs CreateModelRequestTemplateInput `json:"templateInputs,omitempty"`
TemplateId string `json:"templateId,omitempty"`
}
type CreateModelRequestTemplateInput struct {
Input string `json:"input,omitempty"`
InputId string `json:"inputId,omitempty"`
}
type CreateModelResp struct {
ModelId string `json:"modelId,omitempty"`
}

View File

@ -0,0 +1,59 @@
package httpmodelarts
import (
"bytes"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/model"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"net/http"
)
func CreateModel(ctx *gin.Context) {
var param CreateModelReq
var createModelResp CreateModelResp
if err := ctx.BindJSON(&param); err != nil {
model.Response(ctx, http.StatusBadRequest, "invalid request params", err)
return
}
platform, _ := util.GetModelArtsConfWithPlatform("modelarts-CloudBrain2")
reqByte, _ := json.Marshal(param)
// 解析JSON字符串为map[string]interface{}
var originalMap map[string]interface{}
err := json.Unmarshal(reqByte, &originalMap)
if err != nil {
fmt.Println("Error unmarshalling JSON:", err)
return
}
// 转换键名
convertedMap := convertKeys(originalMap)
// 将转换后的map序列化为JSON字符串
convertedJson, err := json.MarshalIndent(convertedMap, "", " ")
body, err := util.SendRequestHttp("POST", platform.Endpoint+"v1/"+platform.ProjectId+"/models",
bytes.NewBuffer(convertedJson), "modelarts-CloudBrain2")
if err != nil {
model.Response(ctx, 500, "failed to invoke", err)
return
}
var originalcamelCaseMap map[string]interface{}
error := json.Unmarshal(body, &originalcamelCaseMap)
if error != nil {
fmt.Println("Error unmarshalling JSON:", err)
return
}
// 转换键名
convertedcamelCaseMap := convertCamelCaseKeys(originalcamelCaseMap)
// 将转换后的map序列化为JSON字符串
convertedCamelCaseJson, err1 := json.MarshalIndent(convertedcamelCaseMap, "", " ")
if err1 != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
json.Unmarshal(convertedCamelCaseJson, &createModelResp)
model.Response(ctx, http.StatusOK, "success", createModelResp)
}

View File

@ -0,0 +1,96 @@
package httpmodelarts
import (
"strings"
"unicode"
)
// toSnakeCase 将驼峰式的字符串转换为下划线式
func toSnakeCase(s string) string {
var builder strings.Builder
for _, r := range s {
if unicode.IsUpper(r) {
if builder.Len() > 0 {
builder.WriteByte('_')
}
builder.WriteRune(unicode.ToLower(r))
} else {
builder.WriteRune(r)
}
}
return builder.String()
}
// convertKeys 递归地将map中的键从驼峰式转换为下划线式
func convertKeys(m map[string]interface{}) map[string]interface{} {
newMap := make(map[string]interface{})
for k, v := range m {
newKey := toSnakeCase(k)
switch val := v.(type) {
case map[string]interface{}:
// 递归处理嵌套map
newMap[newKey] = convertKeys(val)
case []interface{}:
// 对于数组递归处理每个元素如果元素是map的话
var newSlice []interface{}
for _, item := range val {
if itemMap, ok := item.(map[string]interface{}); ok {
newSlice = append(newSlice, convertKeys(itemMap))
} else {
newSlice = append(newSlice, item)
}
}
newMap[newKey] = newSlice
default:
// 对于其他类型,直接赋值
newMap[newKey] = val
}
}
return newMap
}
// toCamelCase 将下划线式的字符串转换为驼峰式
func toCamelCase(s string) string {
words := strings.Split(s, "_")
var camelCase string
for i, word := range words {
// 除了第一个单词外,其他单词的首字母大写
if i == 0 {
camelCase += strings.ToLower(word)
} else {
camelCase += strings.Title(strings.ToLower(word))
}
}
return camelCase
}
// convertKeys 递归地将map中的键从下划线式转换为驼峰式
func convertCamelCaseKeys(m map[string]interface{}) map[string]interface{} {
newMap := make(map[string]interface{})
for k, v := range m {
newKey := toCamelCase(k)
switch val := v.(type) {
case map[string]interface{}:
// 递归处理嵌套map
newMap[newKey] = convertCamelCaseKeys(val)
case []interface{}:
// 对于数组递归处理每个元素如果元素是map的话
var newSlice []interface{}
for _, item := range val {
if itemMap, ok := item.(map[string]interface{}); ok {
newSlice = append(newSlice, convertCamelCaseKeys(itemMap))
} else {
newSlice = append(newSlice, item)
}
}
newMap[newKey] = newSlice
default:
// 对于其他类型,直接赋值
newMap[newKey] = val
}
}
return newMap
}

View File

@ -0,0 +1,15 @@
package model
import (
"github.com/gin-gonic/gin"
"net/http"
)
func Response(c *gin.Context, code int, msg interface{}, data interface{}) {
c.JSON(http.StatusOK, map[string]interface{}{
"code": code,
"msg": msg,
"data": data,
})
return
}

View File

@ -26,10 +26,6 @@ func SignClient(r *http.Request, Platform string) (*http.Client, error) {
projectId = C.ModelArtsConf.CloudBrain2.ProjectId
ak = C.ModelArtsConf.CloudBrain2.AK
sk = C.ModelArtsConf.CloudBrain2.SK
case C.ModelArtsConf.Njaci.Platform:
projectId = C.ModelArtsConf.CloudBrain2.ProjectId
ak = C.ModelArtsConf.Njaci.AK
sk = C.ModelArtsConf.Njaci.SK
default:
return nil, fmt.Errorf("platform %s not supported", Platform)
}
@ -86,13 +82,40 @@ func SendRequest(method, url string, in io.Reader, Platform string) (*[]byte, er
return &body, nil
}
func SendRequestHttp(method, url string, in io.Reader, Platform string) ([]byte, error) {
r, err := http.NewRequest(method, url, in)
if err != nil {
fmt.Println("Error creating new request:", err)
return nil, err
}
signedR, err := SignClient(r, Platform)
if err != nil {
fmt.Println("Error signing request:", err)
return nil, err
}
res, err := signedR.Do(r)
if err != nil {
fmt.Println("Error sending request:", err)
return nil, err
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return nil, err
}
return body, nil
}
func GetModelArtsConfWithPlatform(platform string) (*config.Conf, error) {
var conf config.Conf
switch platform {
case C.ModelArtsConf.CloudBrain2.Platform:
conf = C.ModelArtsConf.CloudBrain2
case C.ModelArtsConf.Njaci.Platform:
conf = C.ModelArtsConf.Njaci
default:
return nil, fmt.Errorf("platform not supported")
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/pkg/cron"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/util"
"gitlink.org.cn/JointCloud/pcm-modelarts/routers"
imagesserviceServer "gitlink.org.cn/JointCloud/pcm-modelarts/internal/server/imagesservice"
modelartsserviceServer "gitlink.org.cn/JointCloud/pcm-modelarts/internal/server/modelartsservice"
@ -33,6 +34,9 @@ func main() {
}
})
defer s.Stop()
//
rt, _ := routers.InitRouter(nil)
_ = rt.Run(":2025")
// 启动并添加定时任务
ctx.Cron.Start()
cron.AddCronGroup(ctx)

31
routers/router.go Normal file
View File

@ -0,0 +1,31 @@
package routers
import (
"github.com/gin-gonic/gin"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/config"
"gitlink.org.cn/JointCloud/pcm-modelarts/internal/logic/httpmodelarts"
)
func InitRouter(conf *config.Configuration) (*gin.Engine, error) {
r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
//api分组
apiv1 := r.Group("/api/v1")
{
//model
model := apiv1.Group("model")
model.POST("/create", httpmodelarts.CreateModel)
//datasets
datasets := apiv1.Group("datasets")
datasets.POST("/create", httpmodelarts.CreateDataset)
//algorithms
algorithms := apiv1.Group("algorithms", httpmodelarts.CreateAlgorithms)
algorithms.POST("/create")
}
return r, nil
}