Giter VIP home page Giter VIP logo

gitlab-skyline's Introduction

Your Gitlab's contributions in a 3D Skyline

gitlab-skyline is a Python command to generate a skyline figure from Gitlab contributions as Github did at https://skyline.github.com/

~ usage: gitlab-skyline [-h] [--domain [DOMAIN]] [--max_requests [MAX_REQUESTS]] username [year]

Create STL from Gitlab contributions

positional arguments:
  username              Gitlab username (without @)
  year                  Year of contributions to fetch

optional arguments:
  -h, --help            show this help message and exit
  --domain [DOMAIN]     GitlabEE/CE custom domain
  --max_requests [MAX_REQUESTS]
                        Max. simultaneous requests to Gitlab. Don't mess with their server!

Enjoy!

View a sample result of the preview at samples/gitlab_felixgomez_2020.stl and OpenSCAD generated code at samples/gitlab_felixgomez_2020.scad.

Requirements and installation

gitlab-skyline requires python3 and OpenSCAD. (need Python version >= 3.7)

Create your virtual environment as usual and install dependencies with

pip install -r requirements.txt

Install OpenSCAD from https://www.openscad.org/downloads.html and ensure that openSCAD executable is working with

openscad --version

Quickstart

python gitlab-skyline felixgomez 2020

or

./gitlab-skyline felixgomez 2020

if file has execution permissions.

If you want to get contributions from a custom installation you can use

./gitlab-skyline felixgomez 2020 --domain="https://customdomain.dev:8080"

Docker Usage

For convience, a docker image is produced to generate the stl image file for you:

docker run -v $PWD:/data registry.gitlab.com/felixgomez/gitlab-skyline <username> [<year>]

Example: docker run -v $PWD:/data registry.gitlab.com/felixgomez/gitlab-skyline felixgomez

To use any custom parameters, simply append to the docker run command.

Using it in private/custom Gitlab installations

As said before, you can use it in custom installations through the --domain modifier.

Don't forget to make your contributions public in your user profile settings.

Motivation

A few days ago I came across the Github skyline web application and it seemed like a good idea to be able to export the activity in skyline format to STL.

It quickly became viral among my friends, but in my daily work I use Gitlab more. That's when I came up with the idea to replicate it for Gitlab: I needed to have my own contribution skyline!

Some details

The project was developed on a Friday afternoon, although I had consulted some information previously, so do not expect quality code and wonders. As always pull requests are welcome! ๐Ÿ˜

At first I was thinking to use the well known Gitlab endpoint https://gitlab.com/users/username/calendar.json but the information it provides is for one year back from now.

As far as I know Gitlab does not provide an endpoint to obtain contribution information by year but digging a bit I found that a call to https://gitlab.com/users/username/calendar_activities?date=2021-02-01 returns an HTML response easy to scrape.

I made use of classic BeautifulSoup for scraping, aiohttp and asyncio to go asynchronous and speed up the scraping process.

There is an extra option (--max-requests) to the gitlab-skyline command to control concurrent requests to Github to avoid the "Too many requests" message from their server.

SolidPython is a beautiful piece of code allowing to generate OpenSCAD code from Python.

Inkscape was used to vectorize the Gitlab logo for extrusion (pending to correct the Viewbox due to lack of time).

Mesh optimization

I love openSCAD for a long time but there are some old well known issues related with errors in the generated geometry. If you detect some on the final STL you could use https://www.meshlab.net/ to correct them.

Thanks!

I hope you like it!

gitlab-skyline's People

Contributors

felixgomez avatar martynbristow avatar setomits avatar yihong0618 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gitlab-skyline's Issues

Ask for license

Hi~

Thank you for your great job.

I maybe kind of use some of your code for my repo, but I notice that your repo doesn't contain License, So I don't know I can use or not.

Can I know which Open Source License you use.

Thank you very much.

RuntimeError: Event loop is closed

image

Error:

Traceback (most recent call last):
  File "gitlab-skyline", line 190, in <module>
    main()
  File "gitlab-skyline", line 186, in main
    generate_skyline_stl(username, year, contribution_matrix)
  File "gitlab-skyline", line 57, in generate_skyline_stl
    year_contribution_list, max_contributions_by_day = parse_contribution_matrix(contribution_matrix)
  File "gitlab-skyline", line 45, in parse_contribution_matrix
    np_contribution_matrix.view('i8,i8,i8').sort(order=['f0'], axis=0)
ValueError: When changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001DB9823B670>
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Error: coroutine 'get_contributions' was never awaited

When I try to create a skyline from a privat gitlab instance using docker, I get an error about coroutine 'get_contributions' was never awaited

docker run -v $PWD:/data gitlab-skyline --token ***[redacted]*** --domain ***[redacted]*** manuel.schiller 2022
/app/gitlab-skyline:186: DeprecationWarning: There is no current event loop
  loop = asyncio.get_event_loop()
Fetching contributions from Gitlab...
Traceback (most recent call last):
  File "/app/gitlab-skyline", line 198, in <module>
    main()
  File "/app/gitlab-skyline", line 187, in main
    loop.run_until_complete(
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 415, in wait
    raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.
sys:1: RuntimeWarning: coroutine 'get_contributions' was never awaited

FileNotFoundError

Hello! I'm running the program on Windows 7 with Python 3.7.9 and got an error attempting the sample quick start command

python gitlab-skyline felixgomez 2020

Fetching contributions from Gitlab...
Generating STL...
Traceback (most recent call last):
  File "gitlab-skyline", line 198, in <module>
    main()
  File "gitlab-skyline", line 194, in main
    generate_skyline_stl(username, year, contribution_matrix)
  File "gitlab-skyline", line 153, in generate_skyline_stl
    capture_output=True)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 488, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

I see that line 153 in generate_skyline_stl is the subprocess run for openSCAD, I checked that I have openSCAD installed and the path added to my system env variables. Any chance someone could give insight on if openSCAD is installed incorrectly or if it's looking for files that weren't generated properly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.