Giter VIP home page Giter VIP logo

gin-valid's Introduction

Build Coverage Status Go Report Card PkgGoDev Docker Automated build

gin-valid

gin-valid is the G-Node Infrastructure data validation service. It is a microservice server written in go that is meant to be run dependent on a [https://github.com/G-Node/gogs](GIN repository server).

Repositories on a GIN server can trigger validation of data files via this service. The currently supported validators are listed below.

  • The BIDS fMRI data format.
  • The NIX (Neuroscience Information Exchange) format.
  • The odML (open metadata markup language) format.

Contributing

For instructions on how to create and add custom validators, please check the adding validators contribution guide.

gin-valid's People

Contributors

achilleas-k avatar cervenkam avatar dependabot[bot] avatar mpsonntag avatar pavelsne avatar

Watchers

 avatar  avatar  avatar  avatar

gin-valid's Issues

Missing annex content handling

When validating a repository that contains files with missing annex content, the validation stops with an error message.

Ideally the validation should not be stopped, but should continue and each file with missing content should be reported as an individual error for each file.

Proper status codes

The function TestValidateTMPFail tests that the validation fails, but because the problem is correctly delivered to the user, the result code of the request is 200 OK. The same applies to the test function TestValidateBadgeFail.

func TestValidateTMPFail(t *testing.T) {

func TestValidateBadgeFail(t *testing.T) { //TODO

Are the results codes obtained from the tested functions correct in this case?

Repo listing page with options to enable hooks

On login the user should be redirected to a repository listing. For each repository, there should be a count showing the number of enabled hooks. On clicking the link of a repository, there should be a page that allows the user to enable or disable hooks for specific validators for the repository.

Unify results rendering

The results rendering functions (renderBidsResults() and renderNIXResults()) still duplicate a lot of code that could be moved to the Results() function. We could shrink these two functions so that :

  • Make the main Results() function parse the layout template.
  • The Results() function could also parse the template for each validator and then we can make the renderBidsResults() and renderNIXResults() functions simply return an interface{} which contains the data required to execute the template.

We could go one step further and have a single template for all validation results. Each function would then have to return a byte slice of their results as text instead of having them structured. The template would then simply add the text to the body of the common template.

Refactor web constants and settings

The web package currently features a couple of package wide constants and variables that are used in various files of the package. As a proposal:

Constants that are used in multiple files could be moved to its own settings.go or config.go file within the package and imported from there so we don't have to look for the file in which they are defined, e.g.

  • cookie name "gin-valid-session"
  • sessions
  • usersession
  • hookregs

Constants that we might not want to have in the code or would make sense to define on server level could also be handled in the settings and imported via the server config e.g.

  • serveralias
  • hooksecret
  • clientID "gin-valid"

BIDS validation on a non-BIDS repo results in a blank 500 page

When running a validation on a non-BIDS repository, the "Results" page should not be a blank 500 page, but a full gin-valid page with an appropriate issue description and an option to return to the "one-time validation" or validator listing page.

Access control

Access control is very basic currently. Hooks can only be enabled by authorised users that have write access to a repository. Beyond that, it's all pretty open. Results are publicly visible and can easily be guessed since the URL is simply constructed from the repository path and the name of the validator.

  • Limit access to results pages based on user access through GIN. We should probably use the token we store for the user to check for read access.
  • Generate unique random identifiers for pub-validate results that are only available to the user that started the validation procedure.

ServiceWaiter/User handling

To avoid any issues, the ServiceWaiter should always remain logged in, every user specific session should create and on finish delete its own session key.

Display logged in user

Display user information in the page header if a user has logged into the gin-valid service.

Support menu "logout"

Currently after a user has logged into the gin-valid service, the "Login" option is still displayed and active.

After a user has logged into the gin-valid service, the "Login" option should be replaced by a functioning "Logout" option.

Handle temporarily unavailable annex content

If (annexed) content is not available yet, wait and retry. We would have to set a max timeout for this. The issue is that when a user does a 'gin upload' a push happens immediately and the hook is triggered, but annexed content is only transferred after the push and could take a while (hours?). The validation service should try to download content after the transfer is complete, or should keep retrying until it's available, with a timeout. We could also make it more efficient by only downloading the content in the directories which are specified in the validator config (if it exists).

NIX validation script

Write a NIX validation script, like the odML script, that uses NIXPy (the nixpy validator could use some fixing up first), formats the output into JSON and prints it. Gin-valid can then read it and format it accordingly into a nice template like we do for BIDS.

Refactor failed login page

Refactor the page displayed via the web/user.go:Login function when a login fails. Display additional information and a link back to the login page for now.

Update nixio validator usage

The previously used nixio-validate executable is no longer installed, the functionality has been integrated into the nixio executable. Usage has been changed from nixio-validate [nixfile(s)] to nixio validate [nixfile(s)].

Change the nixio validate usage accordingly in config.go and validate.go.

Worker queue

Currently requests get run immediately as they come in. We should implement a worker queue for managing concurrent jobs up to a configurable maximum.

When a request comes in, it should write the "In Progress" badge immediately and then queue up to run the validation.

Provide page on missing validation results

Currently when a logged in user views the validator listing page for a specific repository and there are no results for a specific validator yet, the "Results" link for this validator will lead to a blank page with only the text "404 Nothing to see here ...".

Provide a full page including header and footer, an appropriate information text and a link back to the results overview page of the repository.

Disentangle log from server config

If we want to reuse parts of the server for similar micro service servers, it might be useful to remove the gin-valid server config dependency from the logger.

Listing repositories can be very slow

When a user has a lot of repositories it can take very long for the service to get the full list in order to show it on the repo list page. The service should use paging or progressive loading to avoid having the page hang while waiting for a response.

Verify enabled hooks on listing

For each validator the service knows to be enabled, verify with the server that the hook does in fact exist and is active. If a hook has been deleted from the GIN server, either remove it from the local store or warn the user that it's missing.

As a side-feature, avoid enabling duplicate hooks.

Add dynamic (c) date in page footer

Currently the (c) G-Node date in the footer line of each page is static. Replace the static end date with a dynamic one of to the current year.

Handle private repos on "PubValidate"

When a repository is validated using ServiceWaiter via web/validate.go:PubValidate, only public repositories should be validated.

If we ever encounter a private repository in this route, fail with http.StatusUnauthorized and log all details.

Reuse "fail" function

The web packages makes use of a local fail function in case of internal server errors in multiple places. Make the function global and reuse it.

Redirect logged in users to repo listing

When a user lands on the root page (or even the login page), redirect them to their repo listing.

This will make it impossible for a logged in user to reach the manual validation form, so we should either add that to the repo listing or have it as a separate page.

We should probably restructure the validation process

We should probably restructure the validation process

  • Once a validation has started, the service should create a processing badge for the commit and return, so the user does not have to wait until cloning and validation is done (which might take some time).
  • Currently a validation process never returns an error. If something goes wrong during the validation an error should be returned here; if an error is present, the service should then replace the processing badge with an appropriate error badge. If no error is present it is assumed that the build went through and an appropriate badge has been created by the validation process.

Originally posted by @mpsonntag in #33

http.Method handling

Currently http.Methods in the web package are checked within the functions mapped to a route and ended with an InternalServerError, if the used method is not supported for this route.

Either let the muliplexer already take care of the supported methods e.g.

r := mux.NewRouter()
r.Methods("GET", "POST").HandleFunc("/login", web.Login)

or return with the proper http.StatusMethodNotAllowed (405).

[Dockerfile] Ensure validators are working on image build

Currently the validators are just installed but not run on docker build. It might be a good idea to run them once on building the docker image to ensure that they are working as they are used by the go binary.

As an example: the usage of the nixio changed, the install succeeded, but the validation did no longer work as intended.

"Back to GIN" link should be dynamic

Currently its hardcoded to gin.g-node.org which is fine for the live service, but for development and testing purposes it would be nice to set this link via the config.

Exclude validation by repository size

The service should feature the option to exclude a repository from validation, if its annex content is above a certain size. This avoids huge repositories spamming the storage.

The repository size should be defined via the config file.

Add icon to signify external links

The two Repository links on the Repo list page, "Repository on GIN" and "Repository hooks" link to the GIN server. We should add an external link icon (maybe ๐Ÿ”—?) to signify that this links offsite.

Manual build trigger button

Add a button to the repository page repos/<user>/<repo>/hooks to trigger a build manually at the current HEAD. This will be useful for the first build when a user initially enables a hook and would like to test.

Results history

The results page should show a history of past results. The page should show the latest results (or the "In progress" message accordingly) and on a sidebar we should have a list of the results of all the previous runs.

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.