Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lack of documentation on http+json requests example #5158

Closed
2 tasks done
secureness opened this issue Mar 30, 2024 · 4 comments
Closed
2 tasks done

lack of documentation on http+json requests example #5158

secureness opened this issue Mar 30, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@secureness
Copy link

Description

Hi, I really need to work directly with HTTP requests, I read that you have grpc-gateway, but there are no examples in the documentation of how we can use HTTP requests instead of a command like:

 pyflyte --verbose run --remote -p my-project -d development my-project.py say_hello --name myProject

Are you sure this issue hasn't been raised already?

  • Yes

Have you read the Code of Conduct?

  • Yes
@secureness secureness added documentation Improvements or additions to documentation untriaged This issues has not yet been looked at by the Maintainers labels Mar 30, 2024
Copy link

welcome bot commented Mar 30, 2024

Thank you for opening your first issue here! 🛠

Copy link

dosubot bot commented Mar 30, 2024

Hey @secureness, fancy seeing you back here! Hope you're ready to dive into more Flyte adventures. 🚀

Based on your request, it seems you're looking to use HTTP+JSON requests as an alternative to command-line operations in Flyte. While the Flyte documentation may not provide explicit examples of this, it's certainly possible to achieve this by interacting with the Flyte Admin API.

The Flyte Admin API provides a comprehensive set of endpoints for managing workflows, tasks, projects, and their associated data and attributes. You can use these endpoints to perform operations such as running a workflow, listing workflows, and more.

Here's a simplified example of how you might structure a Go code to make a generic HTTP+JSON request to run a workflow:

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	// Example JSON payload
	workflowData := map[string]interface{}{
		"project": "admintests",
		"domain":  "development",
		"name":    "example_workflow",
		// Add other necessary fields here
	}
	jsonData, err := json.Marshal(workflowData)
	if err != nil {
		panic(err)
	}
	// Replace with the actual URL of the Flyte Admin API endpoint for running a workflow
	url := "http://flyteadmin.example.com/api/v1/workflows/run"
	request, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
	if err != nil {
		panic(err)
	}
	// Set headers
	request.Header.Set("Content-Type", "application/json")
	// Send the request
	client := &http.Client{}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()
	// Read and process the response
	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println("Response:", string(body))
	// Process the response as needed
}

This example demonstrates how to construct and send a JSON payload to a hypothetical Flyte Admin API endpoint for running a workflow. You'll need to adjust the workflowData map and the URL to match the specific requirements of the Flyte Admin API endpoint you're targeting.

For more details on the specific API endpoints available in the Flyte Admin API for running workflows and other operations, you can refer to the FlyteIDL files in the Flyte repository:

These files provide a comprehensive list of the available API endpoints and their associated operations.

I hope this helps! If you have any further questions or need more specific examples, please let me know.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@pingsutw
Copy link
Member

@secureness We expose an open API definition endpoint (localhost:30080/api/v1/openapi), you can use it on the swagger UI to see the HTTP request example.

https://docs.flyte.org/en/latest/reference/swagger.html#reference-swagger

@pingsutw pingsutw removed the untriaged This issues has not yet been looked at by the Maintainers label Mar 31, 2024
@secureness
Copy link
Author

@pingsutw Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants