AWS-是否可以将参数从AWS lambda函数传递到AWS sagemaker笔记本

时间:2020-09-11 15:18:25

标签: amazon-web-services aws-lambda amazon-sagemaker

我是AWS控制台的初学者。构建机器学习管道时,我遇到了问题。

当前,Lambda函数可以从前端获取上载的文件名,用户名并调用笔记本实例。

此外,实例上的生命周期配置将调用笔记本进行培训。因此,问题是如何将上述变量变量传递给Sagemaker Notebook以训练机器学习模型。有可能实现这一目标吗?谢谢。

from PyQt5 import QtCore, QtGui, QtWidgets

class Mainwindow(QtWidgets.QMainWindow):
    def __init__(self):
        super(Mainwindow, self).__init__()

        # window setting
        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)

        # window central widget
        self.centerwidget = QtWidgets.QWidget()
        self.setCentralWidget(self.centerwidget)

        # stack for page/widget management
        self.stack = QtWidgets.QStackedLayout(self.centerwidget)

        # widgets or page management
        self.widgeta = None
        self.dockWidget = None
        self.widgetb= None

    def pageManager(self, widget):

        # switching stack widgets 
        self.stack.setCurrentWidget(widget)
        widget.updateGeometry()
        widget.layout.update()
        self.centerwidget.updateGeometry()
        self.updateGeometry()
        self.resize(widget.layout.totalSizeHint())

    def load(self):
        # basically startup
        # stack settings
        self.widgeta= Widgeta()
        self.widgetb= Widgetb()
        self.stack.addWidget(self.widgeta)
        self.stack.addWidget(self.widgetb)
        self.stack.setStackingMode(QtWidgets.QStackedLayout.StackOne)
        self.stack.setCurrentWidget(self.widgeta)

        # dock widget
        self.dockWidget = Duck()
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.dockWidget)

        # show mainwindow
        self.show()

class Duck(QtWidgets.QDockWidget):
    def __init__(self, parent=None):
        super(Duck, self).__init__(parent)
        # create subwidget assign layout to subwidget
        self.dockCentralWidget = QtWidgets.QWidget()
        self.dockCentralWidgetlayout = QtWidgets.QHBoxLayout()
        self.dockCentralWidgetlayout.setContentsMargins(QtCore.QMargins(1,1,1,1))
        self.dockCentralWidgetlayout.setSpacing(1)
        self.dockCentralWidget.setLayout(self.dockCentralWidgetlayout)
        self.dockCentralWidget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        self.setStyleSheet("background-color: #354465;")
        # subwidget elements
        self.Ui()
        # add subwidget and elements
        self.setWidget(self.dockCentralWidget)
        self.dockCentralWidgetlayout.addWidget(self.widgetAButton)
        self.dockCentralWidgetlayout.addWidget(self.widgetBButton)
        
    def Ui(self):
        # first button
        self.widgetAButton = QtWidgets.QPushButton('aaaa')
        self.widgetAButton.clicked.connect(lambda : self.clicker((self.widgetAButton, Window.widgeta)))
        # second button 
        self.widgetBButton = QtWidgets.QPushButton('bbbb')
        self.widgetBButton.clicked.connect(lambda : self.clicker((self.widgetBButton, Window.widgetb)))
    
    def clicker(self, arg):
        Window.pageManager(arg[1])

class Widgeta(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(Widgeta, self).__init__(parent)

        # sizing and layout
        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self.layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.layout)

        # widgets
        self.ui()
    
    def ui(self):
        # a check button
        self.goButton = QtWidgets.QPushButton()
        self.goButton.setObjectName('gobutton')
        self.goButton.setText('ccc')
        self.goButton.setMinimumSize(QtCore.QSize(400, 150))
        self.goButton.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        self.goButton.setStyleSheet(goButtonCSS)

        # label
        self.infoLabel = QtWidgets.QLabel()
        self.infoLabel.setObjectName('infolabel')
        self.infoLabel.setMinimumSize(QtCore.QSize(400, 250))
        self.infoLabel.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        self.infoLabel.setText('jjjj')
        self.infoLabel.setStyleSheet(topDisplayCSS)

        # add widgets to layout
        self.layout.addWidget(self.infoLabel)
        self.layout.addWidget(self.goButton, QtCore.Qt.AlignVCenter, QtCore.Qt.AlignHCenter)
        self.layout.setContentsMargins(QtCore.QMargins(0,0,0,0))

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    Window = Mainwindow()
    Window.load()
    sys.exit(app.exec_())

sagemaker实例下的生命周期配置:

StackedWidget

0 个答案:

没有答案