How to use Get method of execution Package

Best K6 code snippet using execution.Get

client.go

Source:client.go Github

copy

Full Screen

...139type Pipeline struct {140 pipelineCtx *pb.Context141 pipelineRunCtx *pb.Context142}143func (p *Pipeline) GetRunCtxID() int64 {144 if p == nil {145 return 0146 }147 return p.pipelineRunCtx.GetId()148}149func (p *Pipeline) GetCtxID() int64 {150 if p == nil {151 return 0152 }153 return p.pipelineCtx.GetId()154}155func (p *Pipeline) GetPipelineRoot() string {156 if p == nil {157 return ""158 }159 props := p.pipelineRunCtx.GetCustomProperties()160 root, ok := props[keyPipelineRoot]161 if !ok {162 return ""163 }164 return root.GetStringValue()165}166// Execution is a handle for the current execution.167type Execution struct {168 execution *pb.Execution169 pipeline *Pipeline170}171func (e *Execution) GetID() int64 {172 if e == nil {173 return 0174 }175 return e.execution.GetId()176}177func (e *Execution) String() string {178 if e == nil {179 return ""180 }181 return e.execution.String()182}183func (e *Execution) GetPipeline() *Pipeline {184 if e == nil {185 return nil186 }187 return e.pipeline188}189func (e *Execution) GetExecution() *pb.Execution {190 if e == nil {191 return nil192 }193 return e.execution194}195func (e *Execution) TaskName() string {196 if e == nil {197 return ""198 }199 return e.execution.GetCustomProperties()[keyTaskName].GetStringValue()200}201func (e *Execution) FingerPrint() string {202 if e == nil {203 return ""204 }205 return e.execution.GetCustomProperties()[keyCacheFingerPrint].GetStringValue()206}207// GetPipeline returns the current pipeline represented by the specified208// pipeline name and run ID.209func (c *Client) GetPipeline(ctx context.Context, pipelineName, pipelineRunID, namespace, runResource, pipelineRoot string) (*Pipeline, error) {210 pipelineContext, err := c.getOrInsertContext(ctx, pipelineName, pipelineContextType, nil)211 if err != nil {212 return nil, err213 }214 runMetadata := map[string]*pb.Value{215 keyNamespace: stringValue(namespace),216 keyResourceName: stringValue(runResource),217 // pipeline root of this run218 keyPipelineRoot: stringValue(strings.TrimRight(pipelineRoot, "/") + "/" + path.Join(pipelineName, pipelineRunID)),219 }220 pipelineRunContext, err := c.getOrInsertContext(ctx, pipelineRunID, pipelineRunContextType, runMetadata)221 if err != nil {222 return nil, err223 }224 err = c.putParentContexts(ctx, &pb.PutParentContextsRequest{225 ParentContexts: []*pb.ParentContext{{226 ChildId: pipelineRunContext.Id,227 ParentId: pipelineContext.Id,228 }},229 })230 if err != nil {231 return nil, err232 }233 return &Pipeline{234 pipelineCtx: pipelineContext,235 pipelineRunCtx: pipelineRunContext,236 }, nil237}238// a Kubeflow Pipelines DAG239type DAG struct {240 Execution *Execution241}242// identifier info for error message purposes243func (d *DAG) Info() string {244 return fmt.Sprintf("DAG(executionID=%v)", d.Execution.GetID())245}246func (c *Client) GetDAG(ctx context.Context, executionID int64) (*DAG, error) {247 dagError := func(err error) error {248 return fmt.Errorf("failed to get DAG executionID=%v: %w", executionID, err)249 }250 res, err := c.GetExecution(ctx, executionID)251 if err != nil {252 return nil, dagError(err)253 }254 execution := res.GetExecution()255 // TODO(Bobgy): verify execution type is system.DAGExecution256 return &DAG{Execution: &Execution{execution: execution}}, nil257}258func (c *Client) putParentContexts(ctx context.Context, req *pb.PutParentContextsRequest) error {259 _, err := c.svc.PutParentContexts(ctx, req)260 if err != nil {261 if status.Convert(err).Code() == codes.AlreadyExists {262 // already exists code is expected when multiple requests are sent in parallel263 } else {264 return fmt.Errorf("Failed PutParentContexts(%v): %w", req.String(), err)265 }266 }267 return nil268}269func (c *Client) getExecutionTypeID(ctx context.Context, executionType *pb.ExecutionType) (int64, error) {270 eType, err := c.svc.PutExecutionType(ctx, &pb.PutExecutionTypeRequest{271 ExecutionType: executionType,272 })273 if err != nil {274 return 0, err275 }276 return eType.GetTypeId(), nil277}278func stringValue(s string) *pb.Value {279 return &pb.Value{Value: &pb.Value_StringValue{StringValue: s}}280}281func intValue(i int64) *pb.Value {282 return &pb.Value{Value: &pb.Value_IntValue{IntValue: i}}283}284func doubleValue(f float64) *pb.Value {285 return &pb.Value{Value: &pb.Value_DoubleValue{DoubleValue: f}}286}287// Event path is conceptually artifact name for the execution.288// We cannot store the name as a property of artifact "a", because for example:289// 1. In first task "preprocess", there's an output artifact "processed_data".290// 2. In second task "train", there's an input artifact "dataset" passed from "preprocess"291// task's "processed_data" output.292//293// Now the same artifact is called "processed_data" in "preprocess" task, but "dataset" in294// "train" task, because artifact name is related to the context it's used.295// Therefore, we should store artifact name as a property of the artifact's events296// (connects artifact and execution) instead of the artifact's property.297func eventPath(artifactName string) *pb.Event_Path {298 return &pb.Event_Path{299 Steps: []*pb.Event_Path_Step{{300 Value: &pb.Event_Path_Step_Key{301 Key: artifactName,302 },303 }},304 }305}306func getArtifactName(eventPath *pb.Event_Path) (string, error) {307 if eventPath == nil || len(eventPath.Steps) == 0 {308 return "", fmt.Errorf("failed to get artifact name from eventPath")309 }310 return eventPath.Steps[0].GetKey(), nil311}312// PublishExecution publishes the specified execution with the given output313// parameters, artifacts and state.314func (c *Client) PublishExecution(ctx context.Context, execution *Execution, outputParameters map[string]*structpb.Value, outputArtifacts []*OutputArtifact, state pb.Execution_State) error {315 e := execution.execution316 e.LastKnownState = state.Enum()317 if outputParameters != nil {318 // Record output parameters.319 outputs := &pb.Value_StructValue{320 StructValue: &structpb.Struct{321 Fields: make(map[string]*structpb.Value),322 },323 }324 for n, p := range outputParameters {325 outputs.StructValue.Fields[n] = p326 }327 e.CustomProperties[keyOutputs] = &pb.Value{Value: outputs}328 }329 contexts := []*pb.Context{}330 if execution.pipeline != nil {331 contexts = append(contexts, execution.pipeline.pipelineCtx, execution.pipeline.pipelineRunCtx)332 }333 req := &pb.PutExecutionRequest{334 Execution: e,335 Contexts: contexts,336 }337 for _, oa := range outputArtifacts {338 aePair := &pb.PutExecutionRequest_ArtifactAndEvent{}339 if oa.Artifact.GetId() == 0 {340 glog.Infof("the id of output artifact is not set, will create new artifact when publishing execution")341 aePair = &pb.PutExecutionRequest_ArtifactAndEvent{342 Artifact: oa.Artifact,343 Event: &pb.Event{344 Type: pb.Event_OUTPUT.Enum(),345 Path: eventPath(oa.Name),346 },347 }348 } else {349 aePair = &pb.PutExecutionRequest_ArtifactAndEvent{350 Event: &pb.Event{351 Type: pb.Event_OUTPUT.Enum(),352 Path: eventPath(oa.Name),353 ArtifactId: oa.Artifact.Id,354 },355 }356 }357 req.ArtifactEventPairs = append(req.ArtifactEventPairs, aePair)358 }359 _, err := c.svc.PutExecution(ctx, req)360 return err361}362// metadata keys363const (364 keyDisplayName = "display_name"365 keyTaskName = "task_name"366 keyImage = "image"367 keyPodName = "pod_name"368 keyPodUID = "pod_uid"369 keyNamespace = "namespace"370 keyResourceName = "resource_name"371 keyPipelineRoot = "pipeline_root"372 keyCacheFingerPrint = "cache_fingerprint"373 keyCachedExecutionID = "cached_execution_id"374 keyInputs = "inputs"375 keyOutputs = "outputs"376 keyParentDagID = "parent_dag_id" // Parent DAG Execution ID.377)378// CreateExecution creates a new MLMD execution under the specified Pipeline.379func (c *Client) CreateExecution(ctx context.Context, pipeline *Pipeline, config *ExecutionConfig) (*Execution, error) {380 if config == nil {381 return nil, fmt.Errorf("metadata.CreateExecution got config == nil")382 }383 typeID, err := c.getExecutionTypeID(ctx, &pb.ExecutionType{384 Name: proto.String(string(config.ExecutionType)),385 })386 if err != nil {387 return nil, err388 }389 e := &pb.Execution{390 TypeId: &typeID,391 CustomProperties: map[string]*pb.Value{392 // We should support overriding display name in the future, for now it defaults to task name.393 keyDisplayName: stringValue(config.TaskName),394 keyTaskName: stringValue(config.TaskName),395 },396 LastKnownState: pb.Execution_RUNNING.Enum(),397 }398 if config.Name != "" {399 e.Name = &config.Name400 }401 if config.ParentDagID != 0 {402 e.CustomProperties[keyParentDagID] = intValue(config.ParentDagID)403 }404 if config.ExecutionType == ContainerExecutionTypeName {405 e.CustomProperties[keyPodName] = stringValue(config.PodName)406 e.CustomProperties[keyPodUID] = stringValue(config.PodUID)407 e.CustomProperties[keyNamespace] = stringValue(config.Namespace)408 e.CustomProperties[keyImage] = stringValue(config.Image)409 if config.CachedMLMDExecutionID != "" {410 e.CustomProperties[keyCachedExecutionID] = stringValue(config.CachedMLMDExecutionID)411 }412 if config.FingerPrint != "" {413 e.CustomProperties[keyCacheFingerPrint] = stringValue(config.FingerPrint)414 }415 }416 if config.InputParameters != nil {417 e.CustomProperties[keyInputs] = &pb.Value{Value: &pb.Value_StructValue{418 StructValue: &structpb.Struct{419 Fields: config.InputParameters,420 },421 }}422 }423 req := &pb.PutExecutionRequest{424 Execution: e,425 Contexts: []*pb.Context{pipeline.pipelineCtx, pipeline.pipelineRunCtx},426 }427 for name, ids := range config.InputArtifactIDs {428 for _, id := range ids {429 thisId := id // thisId will be referenced below, so we need a local immutable var430 aePair := &pb.PutExecutionRequest_ArtifactAndEvent{431 Event: &pb.Event{432 ArtifactId: &thisId,433 Path: eventPath(name),434 Type: pb.Event_INPUT.Enum(),435 },436 }437 req.ArtifactEventPairs = append(req.ArtifactEventPairs, aePair)438 }439 }440 res, err := c.svc.PutExecution(ctx, req)441 if err != nil {442 return nil, err443 }444 getReq := &pb.GetExecutionsByIDRequest{445 ExecutionIds: []int64{res.GetExecutionId()},446 }447 getRes, err := c.svc.GetExecutionsByID(ctx, getReq)448 if err != nil {449 return nil, err450 }451 if len(getRes.Executions) != 1 {452 return nil, fmt.Errorf("Expected to get one Execution, got %d instead. Request: %v", len(getRes.Executions), getReq)453 }454 return &Execution{455 pipeline: pipeline,456 execution: getRes.Executions[0],457 }, nil458}459// PrePublishExecution updates an existing MLMD execution with Pod info.460func (c *Client) PrePublishExecution(ctx context.Context, execution *Execution, config *ExecutionConfig) (*Execution, error) {461 e := execution.execution462 if e.CustomProperties == nil {463 e.CustomProperties = make(map[string]*pb.Value)464 }465 e.CustomProperties[keyPodName] = stringValue(config.PodName)466 e.CustomProperties[keyPodUID] = stringValue(config.PodUID)467 e.CustomProperties[keyNamespace] = stringValue(config.Namespace)468 e.LastKnownState = pb.Execution_RUNNING.Enum()469 _, err := c.svc.PutExecution(ctx, &pb.PutExecutionRequest{470 Execution: e,471 })472 if err != nil {473 return nil, err474 }475 return execution, nil476}477// GetExecutions ...478func (c *Client) GetExecutions(ctx context.Context, ids []int64) ([]*pb.Execution, error) {479 req := &pb.GetExecutionsByIDRequest{ExecutionIds: ids}480 res, err := c.svc.GetExecutionsByID(ctx, req)481 if err != nil {482 return nil, err483 }484 return res.Executions, nil485}486func (c *Client) GetExecution(ctx context.Context, id int64) (*Execution, error) {487 executions, err := c.GetExecutions(ctx, []int64{id})488 if err != nil {489 return nil, fmt.Errorf("get execution ID=%v: %w", id, err)490 }491 if len(executions) == 0 {492 return nil, fmt.Errorf("execution ID=%v not found", id)493 }494 if len(executions) > 1 {495 return nil, fmt.Errorf("got %v executions with ID=%v", len(executions), id)496 }497 execution := executions[0]498 pipeline, err := c.GetPipelineFromExecution(ctx, execution.GetId())499 if err != nil {500 return nil, err501 }502 return &Execution{execution: execution, pipeline: pipeline}, nil503}504func (c *Client) GetPipelineFromExecution(ctx context.Context, id int64) (*Pipeline, error) {505 pipelineCtxTypeID, err := c.getContextTypeID(ctx, pipelineContextType)506 if err != nil {507 return nil, err508 }509 runCtxTypeID, err := c.getContextTypeID(ctx, pipelineRunContextType)510 if err != nil {511 return nil, err512 }513 res, err := c.svc.GetContextsByExecution(ctx, &pb.GetContextsByExecutionRequest{514 ExecutionId: &id,515 })516 if err != nil {517 return nil, fmt.Errorf("get contexts of execution ID=%v: %w", id, err)518 }519 pipeline := &Pipeline{}520 for _, context := range res.GetContexts() {521 if context.GetTypeId() == pipelineCtxTypeID {522 if pipeline.pipelineCtx != nil {523 return nil, fmt.Errorf("multiple pipeline contexts found")524 }525 pipeline.pipelineCtx = context526 }527 if context.GetTypeId() == runCtxTypeID {528 if pipeline.pipelineRunCtx != nil {529 return nil, fmt.Errorf("multiple run contexts found")530 }531 pipeline.pipelineRunCtx = context532 }533 }534 return pipeline, nil535}536// GetExecutionsInDAG gets all executions in the DAG, and organize them537// into a map, keyed by task name.538func (c *Client) GetExecutionsInDAG(ctx context.Context, dag *DAG, pipeline *Pipeline) (executionsMap map[string]*Execution, err error) {539 defer func() {540 if err != nil {541 err = fmt.Errorf("failed to get executions in %s: %w", dag.Info(), err)542 }543 }()544 executionsMap = make(map[string]*Execution)545 // Documentation on query syntax:546 // https://github.com/google/ml-metadata/blob/839c3501a195d340d2855b6ffdb2c4b0b49862c9/ml_metadata/proto/metadata_store.proto#L831547 parentDAGFilter := fmt.Sprintf("custom_properties.parent_dag_id.int_value = %v", dag.Execution.GetID())548 // Note, because MLMD does not have index on custom properties right now, we549 // take a pipeline run context to limit the number of executions the DB needs to550 // iterate through to find sub-executions.551 res, err := c.svc.GetExecutionsByContext(ctx, &pb.GetExecutionsByContextRequest{552 ContextId: pipeline.pipelineRunCtx.Id,553 Options: &pb.ListOperationOptions{554 FilterQuery: &parentDAGFilter,555 },556 })557 if err != nil {558 return nil, err559 }560 execs := res.GetExecutions()561 for _, e := range execs {562 execution := &Execution{execution: e}563 taskName := execution.TaskName()564 if taskName == "" {565 return nil, fmt.Errorf("empty task name for execution ID: %v", execution.GetID())566 }567 existing, ok := executionsMap[taskName]568 if ok {569 // TODO(Bobgy): to support retry, we need to handle multiple tasks with the same task name.570 return nil, fmt.Errorf("two tasks have the same task name %q, id1=%v id2=%v", taskName, existing.GetID(), execution.GetID())571 }572 executionsMap[taskName] = execution573 }574 return executionsMap, nil575}576// GetEventsByArtifactIDs ...577func (c *Client) GetEventsByArtifactIDs(ctx context.Context, artifactIds []int64) ([]*pb.Event, error) {578 req := &pb.GetEventsByArtifactIDsRequest{ArtifactIds: artifactIds}579 res, err := c.svc.GetEventsByArtifactIDs(ctx, req)580 if err != nil {581 return nil, err582 }583 return res.Events, nil584}585func (c *Client) GetArtifactName(ctx context.Context, artifactId int64) (string, error) {586 mlmdEvents, err := c.GetEventsByArtifactIDs(ctx, []int64{artifactId})587 if err != nil {588 return "", fmt.Errorf("faild when getting events with artifact id %v: %w", artifactId, err)589 }590 if len(mlmdEvents) == 0 {591 glog.Infof("can't find any events with artifact id %v", artifactId)592 return "", nil593 }594 event := mlmdEvents[0]595 return getArtifactName(event.Path)596}597// GetArtifacts ...598func (c *Client) GetArtifacts(ctx context.Context, ids []int64) ([]*pb.Artifact, error) {599 req := &pb.GetArtifactsByIDRequest{ArtifactIds: ids}600 res, err := c.svc.GetArtifactsByID(ctx, req)601 if err != nil {602 return nil, err603 }604 return res.Artifacts, nil605}606// GetOutputArtifactsByExecutionId ...607// TODO: Support multiple artifacts someday, probably through the v2 engine.608func (c *Client) GetOutputArtifactsByExecutionId(ctx context.Context, executionId int64) (map[string]*OutputArtifact, error) {609 getEventsByExecutionIDsReq := &pb.GetEventsByExecutionIDsRequest{ExecutionIds: []int64{executionId}}610 getEventsByExecutionIDsRes, err := c.svc.GetEventsByExecutionIDs(ctx, getEventsByExecutionIDsReq)611 if err != nil {612 return nil, fmt.Errorf("failed to get events with execution id %v: %w", executionId, err)613 }614 var outputArtifactsIDs []int64615 outputArtifactNamesById := make(map[int64]string)616 for _, event := range getEventsByExecutionIDsRes.Events {617 if *event.Type == pb.Event_OUTPUT {618 outputArtifactsIDs = append(outputArtifactsIDs, event.GetArtifactId())619 artifactName, err := getArtifactName(event.Path)620 if err != nil {621 return nil, err622 }623 outputArtifactNamesById[event.GetArtifactId()] = artifactName624 }625 }626 outputArtifacts, err := c.GetArtifacts(ctx, outputArtifactsIDs)627 if err != nil {628 return nil, fmt.Errorf("failed to get output artifacts: %w", err)629 }630 outputArtifactsByName := make(map[string]*OutputArtifact)631 for _, outputArtifact := range outputArtifacts {632 name, ok := outputArtifactNamesById[outputArtifact.GetId()]633 if !ok {634 return nil, fmt.Errorf("failed to get name of artifact with id %v", outputArtifact.GetId())635 }636 outputArtifactsByName[name] = &OutputArtifact{637 Name: name,638 Artifact: outputArtifact,639 Schema: "", // TODO(Bobgy): figure out how to get schema640 }641 }642 return outputArtifactsByName, nil643}644// Only supports schema titles for now.645type schemaObject struct {646 Title string `yaml:"title"`647}648func SchemaToArtifactType(schema string) (*pb.ArtifactType, error) {649 so := &schemaObject{}650 if err := yaml.Unmarshal([]byte(schema), so); err != nil {651 return nil, err652 }653 // TODO: Also parse properties.654 if so.Title == "" {655 glog.Fatal("No title specified")656 }657 at := &pb.ArtifactType{Name: proto.String(so.Title)}658 return at, nil659}660// RecordArtifact ...661func (c *Client) RecordArtifact(ctx context.Context, outputName, schema string, runtimeArtifact *pipelinespec.RuntimeArtifact, state pb.Artifact_State) (*OutputArtifact, error) {662 artifact, err := toMLMDArtifact(runtimeArtifact)663 if err != nil {664 return nil, err665 }666 at, err := SchemaToArtifactType(schema)667 if err != nil {668 return nil, err669 }670 putTypeRes, err := c.svc.PutArtifactType(ctx, &pb.PutArtifactTypeRequest{ArtifactType: at})671 if err != nil {672 return nil, err673 }674 at.Id = putTypeRes.TypeId675 artifact.TypeId = at.Id676 artifact.State = &state677 if artifact.CustomProperties == nil {678 artifact.CustomProperties = make(map[string]*pb.Value)679 }680 if _, ok := artifact.CustomProperties["display_name"]; !ok {681 // display name default value682 artifact.CustomProperties["display_name"] = stringValue(outputName)683 }684 res, err := c.svc.PutArtifacts(ctx, &pb.PutArtifactsRequest{685 Artifacts: []*pb.Artifact{artifact},686 })687 if err != nil {688 return nil, err689 }690 if len(res.ArtifactIds) != 1 {691 return nil, errors.New("Failed to insert exactly one artifact")692 }693 getRes, err := c.svc.GetArtifactsByID(ctx, &pb.GetArtifactsByIDRequest{ArtifactIds: res.ArtifactIds})694 if err != nil {695 return nil, err696 }697 if len(getRes.Artifacts) != 1 {698 return nil, errors.New("Failed to retrieve exactly one artifact")699 }700 return &OutputArtifact{701 Artifact: getRes.Artifacts[0],702 Name: outputName, // runtimeArtifact.Name is in fact artifact ID, we need to pass name separately703 Schema: runtimeArtifact.GetType().GetInstanceSchema(),704 }, nil705}706// TODO consider batching these requests707func (c *Client) GetOrInsertArtifactType(ctx context.Context, schema string) (typeID int64, err error) {708 defer func() {709 if err != nil {710 err = fmt.Errorf("getOrInsertArtifactType(schema=%q) failed: %w", schema, err)711 }712 }()713 at, err := SchemaToArtifactType(schema)714 if err != nil {715 return 0, err716 }717 getTypesRes, err := c.svc.GetArtifactType(ctx, &pb.GetArtifactTypeRequest{TypeName: at.Name})718 if err != nil {719 return 0, err720 }721 if getTypesRes.GetArtifactType() != nil {722 return getTypesRes.GetArtifactType().GetId(), nil723 }724 putTypeRes, err := c.svc.PutArtifactType(ctx, &pb.PutArtifactTypeRequest{ArtifactType: at})725 if err != nil {726 return 0, err727 }728 return putTypeRes.GetTypeId(), err729}730func (c *Client) FindMatchedArtifact(ctx context.Context, artifactToMatch *pb.Artifact, pipelineContextId int64) (matchedArtifact *pb.Artifact, err error) {731 defer func() {732 if err != nil {733 err = fmt.Errorf("FindMatchedArtifact(artifact=%q) failed: %w", artifactToMatch, err)734 }735 }()736 uris := []string{artifactToMatch.GetUri()}737 getArtifactsByUriRes, err := c.svc.GetArtifactsByURI(ctx, &pb.GetArtifactsByURIRequest{Uris: uris})738 if err != nil {739 return nil, err740 }741 for _, candidateArtifact := range getArtifactsByUriRes.GetArtifacts() {742 matched, err := c.matchedArtifactOrNot(ctx, artifactToMatch, candidateArtifact, pipelineContextId)743 if err != nil {744 return nil, err745 }746 if matched {747 return candidateArtifact, nil748 }749 }750 return nil, nil751}752func (c *Client) matchedArtifactOrNot(ctx context.Context, target *pb.Artifact, candidate *pb.Artifact, pipelineContextId int64) (bool, error) {753 if target.GetTypeId() != candidate.GetTypeId() || target.GetState() != candidate.GetState() || target.GetUri() != candidate.GetUri() {754 return false, nil755 }756 for target_k, target_v := range target.GetCustomProperties() {757 val, ok := candidate.GetCustomProperties()[target_k]758 if !ok || !proto.Equal(target_v, val) {759 return false, nil760 }761 }762 res, err := c.svc.GetContextsByArtifact(ctx, &pb.GetContextsByArtifactRequest{ArtifactId: candidate.Id})763 if err != nil {764 return false, fmt.Errorf("failed to get contextsByArtifact with artifactID=%q: %w", candidate.GetId(), err)765 }766 for _, c := range res.GetContexts() {767 if c.GetId() == pipelineContextId {768 return true, nil769 }770 }771 return false, nil772}773func (c *Client) getContextTypeID(ctx context.Context, contextType *pb.ContextType) (typeID int64, err error) {774 defer func() {775 if err != nil {776 err = fmt.Errorf("getContextTypeID(name=%q) failed: %w", contextType.GetName(), err)777 }778 }()779 cached, ok := c.ctxTypeCache.Load(contextType.GetName())780 if ok {781 typeID, ok = cached.(int64)782 if !ok {783 return 0, fmt.Errorf("bug: incorrect value type cached")784 }785 return typeID, nil786 }787 res, err := c.svc.GetContextType(ctx, &pb.GetContextTypeRequest{TypeName: contextType.Name})788 if err == nil { // no error789 c.ctxTypeCache.Store(contextType.GetName(), res.GetContextType().GetId())790 return res.GetContextType().GetId(), nil791 }792 if status.Convert(err).Code() != codes.NotFound {793 return 0, err794 }795 // only not found error is expected796 putRes, err := c.svc.PutContextType(ctx, &pb.PutContextTypeRequest{ContextType: contextType})797 if err == nil { // no error798 c.ctxTypeCache.Store(contextType.GetName(), putRes.GetTypeId())799 return putRes.GetTypeId(), nil800 }801 if status.Convert(err).Code() != codes.AlreadyExists {802 return 0, err803 }804 // It's expected other tasks may try to create the context type at the same time.805 // Handle codes.AlreadyExists:806 res, err = c.svc.GetContextType(ctx, &pb.GetContextTypeRequest{TypeName: contextType.Name})807 if err != nil {808 return 0, err809 }810 c.ctxTypeCache.Store(contextType.GetName(), res.GetContextType().GetId())811 return res.GetContextType().GetId(), nil812}813func (c *Client) getOrInsertContext(ctx context.Context, name string, contextType *pb.ContextType, customProps map[string]*pb.Value) (*pb.Context, error) {814 // The most common case -- the context is already created by upstream tasks.815 // So we try to get the context first.816 getCtxRes, err := c.svc.GetContextByTypeAndName(ctx, &pb.GetContextByTypeAndNameRequest{TypeName: contextType.Name, ContextName: proto.String(name)})817 if err != nil {818 return nil, fmt.Errorf("Failed GetContextByTypeAndName(type=%q, name=%q)", contextType.GetName(), name)819 }820 // Bug in MLMD GetContextsByTypeAndName? It doesn't return error even when no821 // context was found.822 if getCtxRes.Context != nil {823 return getCtxRes.Context, nil824 }825 // Get the ContextType ID.826 typeID, err := c.getContextTypeID(ctx, contextType)827 if err != nil {828 return nil, err829 }830 // Next, create the Context.831 putReq := &pb.PutContextsRequest{832 Contexts: []*pb.Context{833 {834 Name: proto.String(name),835 TypeId: proto.Int64(typeID),836 CustomProperties: customProps,837 },838 },839 }840 _, err = c.svc.PutContexts(ctx, putReq)841 // It's expected other tasks may try to create the context at the same time,842 // so ignore AlreadyExists error.843 if err != nil && status.Convert(err).Code() != codes.AlreadyExists {844 return nil, fmt.Errorf("Failed PutContext(name=%q, type=%q, typeid=%v): %w", name, contextType.GetName(), typeID, err)845 }846 // Get the created context.847 getCtxRes, err = c.svc.GetContextByTypeAndName(ctx, &pb.GetContextByTypeAndNameRequest{TypeName: contextType.Name, ContextName: proto.String(name)})848 if err != nil {849 return nil, fmt.Errorf("Failed GetContext(name=%q, type=%q): %w", name, contextType.GetName(), err)850 }851 return getCtxRes.GetContext(), nil852}853func GenerateExecutionConfig(executorInput *pipelinespec.ExecutorInput) (*ExecutionConfig, error) {854 ecfg := &ExecutionConfig{855 InputArtifactIDs: make(map[string][]int64),856 }857 for name, artifactList := range executorInput.Inputs.Artifacts {858 for _, artifact := range artifactList.Artifacts {859 id, err := strconv.ParseInt(artifact.Name, 10, 64)860 if err != nil {861 return nil, fmt.Errorf("unable to parse input artifact id from %q: %w", id, err)862 }863 ecfg.InputArtifactIDs[name] = append(ecfg.InputArtifactIDs[name], id)864 }865 }866 ecfg.InputParameters = executorInput.Inputs.ParameterValues867 return ecfg, nil868}869func (c *Client) getContextByID(ctx context.Context, id int64) (*pb.Context, error) {870 res, err := c.svc.GetContextsByID(ctx, &pb.GetContextsByIDRequest{ContextIds: []int64{id}})871 if err != nil {872 return nil, fmt.Errorf("getContext(id=%v): %w", id, err)873 }874 contexts := res.GetContexts()875 if len(contexts) > 1 {876 return nil, fmt.Errorf("getContext(id=%v): got %v contexts, expect 1", id, len(contexts))877 }878 if len(contexts) == 0 {879 return nil, fmt.Errorf("getContext(id=%v): not found", id)880 }881 if contexts[0] == nil {882 return nil, fmt.Errorf("getContext(id=%v): got nil context", id)883 }884 return contexts[0], nil885}...

Full Screen

Full Screen

executions_client.go

Source:executions_client.go Github

copy

Full Screen

...32// CallOptions contains the retry settings for each method of Client.33type CallOptions struct {34 ListExecutions []gax.CallOption35 CreateExecution []gax.CallOption36 GetExecution []gax.CallOption37 CancelExecution []gax.CallOption38}39func defaultGRPCClientOptions() []option.ClientOption {40 return []option.ClientOption{41 internaloption.WithDefaultEndpoint("workflowexecutions.googleapis.com:443"),42 internaloption.WithDefaultMTLSEndpoint("workflowexecutions.mtls.googleapis.com:443"),43 internaloption.WithDefaultAudience("https://workflowexecutions.googleapis.com/"),44 internaloption.WithDefaultScopes(DefaultAuthScopes()...),45 internaloption.EnableJwtWithScope(),46 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(47 grpc.MaxCallRecvMsgSize(math.MaxInt32))),48 }49}50func defaultCallOptions() *CallOptions {51 return &CallOptions{52 ListExecutions: []gax.CallOption{},53 CreateExecution: []gax.CallOption{},54 GetExecution: []gax.CallOption{},55 CancelExecution: []gax.CallOption{},56 }57}58// internalClient is an interface that defines the methods availaible from Workflow Executions API.59type internalClient interface {60 Close() error61 setGoogleClientInfo(...string)62 Connection() *grpc.ClientConn63 ListExecutions(context.Context, *executionspb.ListExecutionsRequest, ...gax.CallOption) *ExecutionIterator64 CreateExecution(context.Context, *executionspb.CreateExecutionRequest, ...gax.CallOption) (*executionspb.Execution, error)65 GetExecution(context.Context, *executionspb.GetExecutionRequest, ...gax.CallOption) (*executionspb.Execution, error)66 CancelExecution(context.Context, *executionspb.CancelExecutionRequest, ...gax.CallOption) (*executionspb.Execution, error)67}68// Client is a client for interacting with Workflow Executions API.69// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.70//71// Executions is used to start and manage running instances of72// Workflows called executions.73type Client struct {74 // The internal transport-dependent client.75 internalClient internalClient76 // The call options for this service.77 CallOptions *CallOptions78}79// Wrapper methods routed to the internal client.80// Close closes the connection to the API service. The user should invoke this when81// the client is no longer required.82func (c *Client) Close() error {83 return c.internalClient.Close()84}85// setGoogleClientInfo sets the name and version of the application in86// the `x-goog-api-client` header passed on each request. Intended for87// use by Google-written clients.88func (c *Client) setGoogleClientInfo(keyval ...string) {89 c.internalClient.setGoogleClientInfo(keyval...)90}91// Connection returns a connection to the API service.92//93// Deprecated.94func (c *Client) Connection() *grpc.ClientConn {95 return c.internalClient.Connection()96}97// ListExecutions returns a list of executions which belong to the workflow with98// the given name. The method returns executions of all workflow99// revisions. Returned executions are ordered by their start time (newest100// first).101func (c *Client) ListExecutions(ctx context.Context, req *executionspb.ListExecutionsRequest, opts ...gax.CallOption) *ExecutionIterator {102 return c.internalClient.ListExecutions(ctx, req, opts...)103}104// CreateExecution creates a new execution using the latest revision of the given workflow.105func (c *Client) CreateExecution(ctx context.Context, req *executionspb.CreateExecutionRequest, opts ...gax.CallOption) (*executionspb.Execution, error) {106 return c.internalClient.CreateExecution(ctx, req, opts...)107}108// GetExecution returns an execution of the given name.109func (c *Client) GetExecution(ctx context.Context, req *executionspb.GetExecutionRequest, opts ...gax.CallOption) (*executionspb.Execution, error) {110 return c.internalClient.GetExecution(ctx, req, opts...)111}112// CancelExecution cancels an execution of the given name.113func (c *Client) CancelExecution(ctx context.Context, req *executionspb.CancelExecutionRequest, opts ...gax.CallOption) (*executionspb.Execution, error) {114 return c.internalClient.CancelExecution(ctx, req, opts...)115}116// gRPCClient is a client for interacting with Workflow Executions API over gRPC transport.117//118// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.119type gRPCClient struct {120 // Connection pool of gRPC connections to the service.121 connPool gtransport.ConnPool122 // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE123 disableDeadlines bool124 // Points back to the CallOptions field of the containing Client125 CallOptions **CallOptions126 // The gRPC API client.127 client executionspb.ExecutionsClient128 // The x-goog-* metadata to be sent with each request.129 xGoogMetadata metadata.MD130}131// NewClient creates a new executions client based on gRPC.132// The returned client must be Closed when it is done being used to clean up its underlying connections.133//134// Executions is used to start and manage running instances of135// Workflows called executions.136func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {137 clientOpts := defaultGRPCClientOptions()138 if newClientHook != nil {139 hookOpts, err := newClientHook(ctx, clientHookParams{})140 if err != nil {141 return nil, err142 }143 clientOpts = append(clientOpts, hookOpts...)144 }145 disableDeadlines, err := checkDisableDeadlines()146 if err != nil {147 return nil, err148 }149 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)150 if err != nil {151 return nil, err152 }153 client := Client{CallOptions: defaultCallOptions()}154 c := &gRPCClient{155 connPool: connPool,156 disableDeadlines: disableDeadlines,157 client: executionspb.NewExecutionsClient(connPool),158 CallOptions: &client.CallOptions,159 }160 c.setGoogleClientInfo()161 client.internalClient = c162 return &client, nil163}164// Connection returns a connection to the API service.165//166// Deprecated.167func (c *gRPCClient) Connection() *grpc.ClientConn {168 return c.connPool.Conn()169}170// setGoogleClientInfo sets the name and version of the application in171// the `x-goog-api-client` header passed on each request. Intended for172// use by Google-written clients.173func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {174 kv := append([]string{"gl-go", versionGo()}, keyval...)175 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)176 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))177}178// Close closes the connection to the API service. The user should invoke this when179// the client is no longer required.180func (c *gRPCClient) Close() error {181 return c.connPool.Close()182}183func (c *gRPCClient) ListExecutions(ctx context.Context, req *executionspb.ListExecutionsRequest, opts ...gax.CallOption) *ExecutionIterator {184 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))185 ctx = insertMetadata(ctx, c.xGoogMetadata, md)186 opts = append((*c.CallOptions).ListExecutions[0:len((*c.CallOptions).ListExecutions):len((*c.CallOptions).ListExecutions)], opts...)187 it := &ExecutionIterator{}188 req = proto.Clone(req).(*executionspb.ListExecutionsRequest)189 it.InternalFetch = func(pageSize int, pageToken string) ([]*executionspb.Execution, string, error) {190 resp := &executionspb.ListExecutionsResponse{}191 if pageToken != "" {192 req.PageToken = pageToken193 }194 if pageSize > math.MaxInt32 {195 req.PageSize = math.MaxInt32196 } else if pageSize != 0 {197 req.PageSize = int32(pageSize)198 }199 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {200 var err error201 resp, err = c.client.ListExecutions(ctx, req, settings.GRPC...)202 return err203 }, opts...)204 if err != nil {205 return nil, "", err206 }207 it.Response = resp208 return resp.GetExecutions(), resp.GetNextPageToken(), nil209 }210 fetch := func(pageSize int, pageToken string) (string, error) {211 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)212 if err != nil {213 return "", err214 }215 it.items = append(it.items, items...)216 return nextPageToken, nil217 }218 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)219 it.pageInfo.MaxSize = int(req.GetPageSize())220 it.pageInfo.Token = req.GetPageToken()221 return it222}223func (c *gRPCClient) CreateExecution(ctx context.Context, req *executionspb.CreateExecutionRequest, opts ...gax.CallOption) (*executionspb.Execution, error) {224 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))225 ctx = insertMetadata(ctx, c.xGoogMetadata, md)226 opts = append((*c.CallOptions).CreateExecution[0:len((*c.CallOptions).CreateExecution):len((*c.CallOptions).CreateExecution)], opts...)227 var resp *executionspb.Execution228 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {229 var err error230 resp, err = c.client.CreateExecution(ctx, req, settings.GRPC...)231 return err232 }, opts...)233 if err != nil {234 return nil, err235 }236 return resp, nil237}238func (c *gRPCClient) GetExecution(ctx context.Context, req *executionspb.GetExecutionRequest, opts ...gax.CallOption) (*executionspb.Execution, error) {239 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))240 ctx = insertMetadata(ctx, c.xGoogMetadata, md)241 opts = append((*c.CallOptions).GetExecution[0:len((*c.CallOptions).GetExecution):len((*c.CallOptions).GetExecution)], opts...)242 var resp *executionspb.Execution243 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {244 var err error245 resp, err = c.client.GetExecution(ctx, req, settings.GRPC...)246 return err247 }, opts...)248 if err != nil {249 return nil, err250 }251 return resp, nil252}253func (c *gRPCClient) CancelExecution(ctx context.Context, req *executionspb.CancelExecutionRequest, opts ...gax.CallOption) (*executionspb.Execution, error) {254 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))255 ctx = insertMetadata(ctx, c.xGoogMetadata, md)256 opts = append((*c.CallOptions).CancelExecution[0:len((*c.CallOptions).CancelExecution):len((*c.CallOptions).CancelExecution)], opts...)257 var resp *executionspb.Execution258 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {259 var err error260 resp, err = c.client.CancelExecution(ctx, req, settings.GRPC...)261 return err262 }, opts...)263 if err != nil {264 return nil, err265 }266 return resp, nil267}268// ExecutionIterator manages a stream of *executionspb.Execution....

Full Screen

Full Screen

windows_malware_execution_state_count.go

Source:windows_malware_execution_state_count.go Github

copy

Full Screen

...24// CreateWindowsMalwareExecutionStateCountFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value25func CreateWindowsMalwareExecutionStateCountFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) {26 return NewWindowsMalwareExecutionStateCount(), nil27}28// GetAdditionalData gets the additionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.29func (m *WindowsMalwareExecutionStateCount) GetAdditionalData()(map[string]interface{}) {30 if m == nil {31 return nil32 } else {33 return m.additionalData34 }35}36// GetDeviceCount gets the deviceCount property value. Count of devices with malware detections for this malware execution state37func (m *WindowsMalwareExecutionStateCount) GetDeviceCount()(*int32) {38 if m == nil {39 return nil40 } else {41 return m.deviceCount42 }43}44// GetExecutionState gets the executionState property value. Malware execution state. Possible values are: unknown, blocked, allowed, running, notRunning.45func (m *WindowsMalwareExecutionStateCount) GetExecutionState()(*WindowsMalwareExecutionState) {46 if m == nil {47 return nil48 } else {49 return m.executionState50 }51}52// GetFieldDeserializers the deserialization information for the current model53func (m *WindowsMalwareExecutionStateCount) GetFieldDeserializers()(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error)) {54 res := make(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error))55 res["deviceCount"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {56 val, err := n.GetInt32Value()57 if err != nil {58 return err59 }60 if val != nil {61 m.SetDeviceCount(val)62 }63 return nil64 }65 res["executionState"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {66 val, err := n.GetEnumValue(ParseWindowsMalwareExecutionState)67 if err != nil {68 return err69 }70 if val != nil {71 m.SetExecutionState(val.(*WindowsMalwareExecutionState))72 }73 return nil74 }75 res["lastUpdateDateTime"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {76 val, err := n.GetTimeValue()77 if err != nil {78 return err79 }80 if val != nil {81 m.SetLastUpdateDateTime(val)82 }83 return nil84 }85 return res86}87// GetLastUpdateDateTime gets the lastUpdateDateTime property value. The Timestamp of the last update for the device count in UTC88func (m *WindowsMalwareExecutionStateCount) GetLastUpdateDateTime()(*i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) {89 if m == nil {90 return nil91 } else {92 return m.lastUpdateDateTime93 }94}95// Serialize serializes information the current object96func (m *WindowsMalwareExecutionStateCount) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {97 {98 err := writer.WriteInt32Value("deviceCount", m.GetDeviceCount())99 if err != nil {100 return err101 }102 }103 if m.GetExecutionState() != nil {104 cast := (*m.GetExecutionState()).String()105 err := writer.WriteStringValue("executionState", &cast)106 if err != nil {107 return err108 }109 }110 {111 err := writer.WriteTimeValue("lastUpdateDateTime", m.GetLastUpdateDateTime())112 if err != nil {113 return err114 }115 }116 {117 err := writer.WriteAdditionalData(m.GetAdditionalData())118 if err != nil {119 return err120 }121 }122 return nil123}124// SetAdditionalData sets the additionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.125func (m *WindowsMalwareExecutionStateCount) SetAdditionalData(value map[string]interface{})() {126 if m != nil {127 m.additionalData = value128 }129}130// SetDeviceCount sets the deviceCount property value. Count of devices with malware detections for this malware execution state131func (m *WindowsMalwareExecutionStateCount) SetDeviceCount(value *int32)() {...

Full Screen

Full Screen

Get

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("ls", "-l")4 stdout, err := cmd.StdoutPipe()5 if err != nil {6 fmt.Println(err)7 }8 if err := cmd.Start(); err != nil {9 fmt.Println(err)10 }11 output, err := ioutil.ReadAll(stdout)12 if err != nil {13 fmt.Println(err)14 }15 fmt.Println(string(output))16}17Example 2: Using Run() method of exec package18import (19func main() {20 cmd := exec.Command("ls", "-l")21 output, err := cmd.Output()22 if err != nil {23 fmt.Println(err)24 }25 fmt.Println(string(output))26}

Full Screen

Full Screen

Get

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("ls", "-l")4 out, err := cmd.Output()5 if err != nil {6 fmt.Println(err)7 os.Exit(1)8 }9 fmt.Println(string(out))10}

Full Screen

Full Screen

Get

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 path, err := exec.LookPath("go")4 if err != nil {5 fmt.Println("Error: ", err)6 os.Exit(1)7 }8 fmt.Println("Path: ", path)9}10import (11func main() {12 path, err := exec.LookPath("go")13 if err != nil {14 fmt.Println("Error: ", err)15 os.Exit(1)16 }17 fmt.Println("Path: ", path)18}19import (20func main() {21 path, err := exec.LookPath("go")22 if err != nil {23 fmt.Println("Error: ", err)24 os.Exit(1)25 }26 fmt.Println("Path: ", path)27}28import (29func main() {30 path, err := exec.LookPath("go")31 if err != nil {32 fmt.Println("Error: ", err)33 os.Exit(1)34 }35 fmt.Println("Path: ", path)36}37import (38func main() {39 path, err := exec.LookPath("go")40 if err != nil {41 fmt.Println("Error: ", err)42 os.Exit(1)43 }44 fmt.Println("Path: ", path)45}

Full Screen

Full Screen

Get

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("ls", "-l")4 stdout, err := cmd.Output()5 if err != nil {6 fmt.Println(err.Error())7 }8 fmt.Println(string(stdout))9}

Full Screen

Full Screen

Get

Using AI Code Generation

copy

Full Screen

1import (2type Student struct {3}4func main() {5 s := Student{rollno: 1, name: "A"}6 v := reflect.ValueOf(s)7 fmt.Println(v)8 fmt.Println(v.Interface())9 fmt.Println(v.Interface().(Student))10}11{1 A}12{1 A}13{1 A}14import (15type Student struct {16}17func main() {18 s := Student{rollno: 1, name: "A"}19 v := reflect.ValueOf(s)20 fmt.Println(v)21 fmt.Println(v.Interface())22 fmt.Println(v.Interface().(Student))23 v.Field(0).SetInt(2)24 v.Field(1).SetString("B")25 fmt.Println(v)26 fmt.Println(v.Interface())27 fmt.Println(v.Interface().(Student))28}29{1 A}30{1 A}31{1 A}32{2 B}33{2 B}34{2 B}35import (36type Student struct {37}38func main() {39 s := Student{rollno: 1, name: "A"}40 v := reflect.ValueOf(&s)41 fmt.Println(v)42 fmt.Println(v.Interface())43 fmt.Println(v.Interface().(Student))44 v.Elem().Field(0).SetInt(2)45 v.Elem().Field(1).SetString("B")46 fmt.Println(v)47 fmt.Println(v.Interface())48 fmt.Println(v.Interface().(Student))49}50&{1 A}51&{1 A}52{1 A}53&{2 B}54&{2 B}55{2 B}56import (57type Student struct {58}59func (s *Student) display() {

Full Screen

Full Screen

Get

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 e := execution.New()4 name, err := e.Get("name")5 if err != nil {6 fmt.Println(err)7 }8 fmt.Println(name)9}10import "fmt"11func main() {12 e := execution.New()13 err := e.Set("name", "Execution")14 if err != nil {15 fmt.Println(err)16 }17}18import "fmt"19func main() {20 e := execution.New()21 name, err := e.Get("name")22 if err != nil {23 fmt.Println(err)24 }25 fmt.Println(name)26}27import "fmt"28func main() {29 e := execution.New()30 err := e.Set("name", "Execution")31 if err != nil {32 fmt.Println(err)33 }34}35import "fmt"36func main() {37 e := execution.New()38 name, err := e.Get("name")39 if err != nil {40 fmt.Println(err)41 }42 fmt.Println(name)43}44import "fmt"45func main() {46 e := execution.New()47 err := e.Set("name", "Execution")48 if err != nil {49 fmt.Println(err)50 }51}52import "fmt"53func main() {54 e := execution.New()

Full Screen

Full Screen

Get

Using AI Code Generation

copy

Full Screen

1func main() {2 e := execution.New()3 out, err := e.Get("ls -la")4 if err != nil {5 panic(err)6 }7 fmt.Println(out)8}9In this tutorial, we will show you how to install and configure the OpenVPN server on Ubuntu 20.04. For those of you who didn’t know, OpenVPN is a free and open-source software application that implements virtual private network (VPN) techniques to create secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities. It uses a custom security protocol that utilizes SSL/TLS for key exchange. It is capable of traversing network address translators

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful