Comments (3)
You can use Github OAuth to sign in to the Gitlab instance
from adaptive.
We have moved the development to GitHub as of today!
from adaptive.
We used the following script:
import re
import gitlab
import github
gitlab_url = 'https://gitlab.kwant-project.org/'
repo_name_gl = 'qt/adaptive'
repo_name_gh = "python-adaptive/adaptive"
# gh = github.Github("...") # Joe
gh = github.Github("...") # Bas
gl = gitlab.Gitlab(gitlab_url, private_token=...', api_version=4)
gl.auth()
repo_gl = gl.projects.get(repo_name_gl)
mrs = repo_gl.mergerequests.list(state='opened')
issues = repo_gl.issues.list(all=True)
repo_gh = gh.get_repo(repo_name_gh)
def random_color():
import random
r = lambda: random.randint(0, 255)
return '%02X%02X%02X' % (r(),r(),r())
def get_label(label):
try:
return repo_gh.create_label(label, color=random_color())
except:
return repo_gh.get_label(label)
def get_issue_body(issue, is_pr=False):
attrs = issue.attributes
author = attrs["author"]
username_url = get_username_url(author["username"])
url = attrs["web_url"]
output = (f'## ([original {"merge request" if is_pr else "issue"} on GitLab]({url}))'
'\n\n'
f'_opened by {author["name"]} ({username_url}) at {attrs["created_at"]}_'
'\n\n'
f'{attrs["description"]}'
)
return parse(output)
def get_comment_body(discussion, url):
attrs = discussion.attributes
note = attrs['notes'][0]
body = note['body']
author = note['author']
username_url = get_username_url(author["username"])
output = (
f'_originally posted by {author["name"]} ({username_url}) at {note["created_at"]} on [GitLab]({url})_'
'\n\n'
f'{body}'
)
return parse(output)
def human_posted(discussion):
return not discussion.attributes['notes'][0]['system']
def get_username_url(username):
url = gitlab_url + username
return f'[@{username}]({url})'
def parse(text):
repo_url = gitlab_url + repo_name_gl
text = re.sub('!(\d{1,3})', rf'[gitlab:!\1]({repo_url}/merge_requests/\1)', text)
text = re.sub('#(\d{1,3})', rf'[gitlab:#\1]({repo_url}/issues/\1)', text)
return text
import time
for issue in issues:
time.sleep(2)
attrs = issue.attributes
labels = [get_label(label) for label in attrs["labels"]]
new_issue = repo_gh.create_issue(title=attrs['title'], body=get_issue_body(issue), labels=labels)
for discussion in issue.discussions.list():
if human_posted(discussion):
time.sleep(0.5)
comment_body = get_comment_body(discussion, attrs['web_url'])
new_issue.create_comment(comment_body)
if issue.attributes['state'] == 'closed':
# Close the issue if closed on GitLab
new_issue.edit(state="closed")
for mr in mrs:
attrs = mr.attributes
new_pr = repo_gh.create_pull(title=attrs['title'],
body=get_issue_body(mr, is_pr=True),
head=attrs['source_branch'],
base=attrs['target_branch'],
maintainer_can_modify=True)
for discussion in mr.discussions.list():
if human_posted(discussion):
comment_body = get_comment_body(discussion, attrs['web_url'])
new_pr.create_issue_comment(comment_body)
from adaptive.
Related Issues (20)
- Question: plot_trisurf (matplotlib) directly from qhull HOT 3
- Incompatibility of adaptive (asyncio) with python=3.10 HOT 4
- Stop using atomic writes HOT 2
- Documentation: use cases of coroutine by Learner and Runner not properly explained HOT 2
- Rename master branch to main HOT 3
- Fix branch name (master --> main) in binder link in readme HOT 1
- No module named 'typing_extensions'" HOT 2
- Learner2D.interpolator and Learner2D.interpolated_on_grid give different results HOT 5
- Target function returns NaN HOT 5
- Use in script with BlockingRunner: get log and/or feedback on progress HOT 4
- Handling with regions unreachable inside the `ConvexHull` in `LearnerND` HOT 2
- large delay when using start_periodic_saving
- Create API for just signle process (No pickle) HOT 2
- Efficient sampling of measurment bound functions: BatchExecutor? HOT 2
- Question on uncertainty quantification HOT 2
- Issues with Multiprocess and AsyncRunner in adaptive for Phase Diagram Illustration HOT 2
- Async Running Problem with AsyncRunner HOT 2
- Normalize variabels HOT 4
- Question: is this applicable for time series?
- [Question] Calculate loss given resampled data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adaptive.