Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

setup_github_dagshub_connection.py 3.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  1. """
  2. Script to help set up the connection between GitHub and DAGsHub.
  3. This script will provide instructions on how to manually set up the connection.
  4. """
  5. import os
  6. from pathlib import Path
  7. from dotenv import load_dotenv
  8. # Load environment variables from .env file
  9. env_path = Path(__file__).parent / '.env'
  10. load_dotenv(dotenv_path=env_path)
  11. # Get DAGsHub credentials from environment variables
  12. dagshub_username = os.getenv("DAGSHUB_USERNAME")
  13. dagshub_token = os.getenv("DAGSHUB_TOKEN")
  14. dagshub_repo = os.getenv("DAGSHUB_REPO")
  15. # Print instructions
  16. print("""
  17. =====================================================================
  18. INSTRUCTIONS FOR CONNECTING GITHUB TO DAGSHUB MANUALLY
  19. =====================================================================
  20. Since you're encountering a 403 error when trying to connect through the web interface,
  21. here's how to set up the connection manually:
  22. 1. GITHUB SETUP:
  23. - Go to your GitHub repository: https://github.com/austinLorenzMccoy/agripreserve
  24. - Navigate to Settings > Webhooks
  25. - Click "Add webhook"
  26. - Set the following values:
  27. * Payload URL: https://dagshub.com/api/v1/webhooks/github
  28. * Content type: application/json
  29. * Secret: (leave blank)
  30. * Which events would you like to trigger this webhook?: "Just the push event"
  31. * Active: Checked
  32. - Click "Add webhook"
  33. 2. DAGSHUB SETUP:
  34. - Go to your DAGsHub repository: https://dagshub.com/austinLorenzMccoy/agripreserve
  35. - Navigate to Settings > Integrations
  36. - Look for GitHub integration and click "Connect"
  37. - Enter your GitHub repository URL: https://github.com/austinLorenzMccoy/agripreserve
  38. - Click "Connect"
  39. 3. ALTERNATIVE APPROACH:
  40. If the above methods don't work, you can manually sync your repositories:
  41. - Add DAGsHub as a second remote to your local repository:
  42. * git remote add dagshub https://austinLorenzMccoy:{token}@dagshub.com/austinLorenzMccoy/agripreserve.git
  43. - Push to both remotes when making changes:
  44. * git push origin main
  45. * git push dagshub main
  46. Your DAGsHub credentials:
  47. - Username: {username}
  48. - Token: {token_masked}
  49. - Repository: {repo}
  50. =====================================================================
  51. """.format(
  52. username=dagshub_username,
  53. token_masked=dagshub_token[:5] + "..." if dagshub_token else "None",
  54. token=dagshub_token,
  55. repo=dagshub_repo
  56. ))
  57. # Print command to add DAGsHub as a remote
  58. print("Command to add DAGsHub as a remote to your Git repository:")
  59. print(f"git remote add dagshub https://{dagshub_username}:{dagshub_token}@dagshub.com/{dagshub_username}/{dagshub_repo}.git\n")
  60. # Check if DAGsHub is already a remote
  61. import subprocess
  62. try:
  63. result = subprocess.run(
  64. ["git", "remote", "-v"],
  65. cwd=str(Path(__file__).parent),
  66. capture_output=True,
  67. text=True,
  68. check=True
  69. )
  70. remotes = result.stdout
  71. print("Current Git remotes:")
  72. print(remotes)
  73. if "dagshub" in remotes:
  74. print("\nDAGsHub is already configured as a remote!")
  75. else:
  76. print("\nDAGsHub is not yet configured as a remote. Use the command above to add it.")
  77. except Exception as e:
  78. print(f"Error checking Git remotes: {str(e)}")
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...