Giter Club home page Giter Club logo

betydb-yaba's People

Contributors

dependabot[bot] avatar dlebauer avatar eshantri avatar im-prakher avatar infotroph avatar kristinariemer avatar mansi-dass avatar saurabh1969 avatar theakhiljha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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

betydb-yaba's Issues

Questions to answer in README/ documentation

@gsrohde brought up the following points in this comment: PecanProject/betydbdoc-dataentry#4 (comment)

These questions should be answered in the README and / or the betydbdoc-dataentry documentation:

  • Does each user who wants to interact with a database have to deploy their own copy of the YABA app?
  • Can it be used to connect to any BETYdb database, or does it have to be run on the same machine where the database lives?
  • What controls the permissions on accessing and altering the database?

Design metadata upload API in swaggerhub

Need to define api endpoints that will be used in the metadata upload workflow https://osf.io/v7f9t/wiki/Metadata%20Entry%20Workflow/

The idea is that you will have an endpoint for each of the add_* functions in https://github.com/az-digitalag/betydbtools/pull/2/files

But probably easiest to follow the sql here https://osf.io/v7f9t/wiki/Metadata%20Entry%20Workflow/

Completion criteria

  • published on swaggerhub
  • add a *.yaml file in openapi 3.0 schema to the repository

Incorrect plot shapes assigned to plots

When loading plots through the YABA interface plot names are not correctly matched up with the shapes in the shapefile leading to incorrect plot boundaries.

Modifying client routes for data validation

The goal of this issue is to implement data validation for shapefiles, spreadsheets before API data ingestion by modifying existing API routes functionality.

BETYdb-YABA/app/Meta.py

Lines 52 to 72 in 64b540e

try:
user_id=fetch_id(username, table='users')
if not user_id:
return 401
#Reading the CSV file into DataFrame
data = pd.read_csv(fileName,delimiter = ',')
#Checking necessary columns are there.
columns=data.columns.values.tolist()
accepted_columns=['name','start_date','end_date','description','design']
if(all(x in accepted_columns for x in columns)):
data['user_id']=user_id
data['design'].fillna('some text', inplace=True)
insert_table(table='experiments',data=data)
msg = {'Message' : 'Successfully inserted',
'Table Affected' : 'Experiments',
'Lines Inserted': data.shape[0]}
return make_response(jsonify(msg), 201)
#

Like, the code in this function responds to /yaba/v1/experiments (for inserting experiments in the BETY database), we can modify this, by accepting one more parameter as status(which can be true or false), if false then return a valid response after validating data otherwise continue with data insertion. In this example, we can check the status after line 64, if true we can return a response from there only and stop further execution otherwise continue with data insertion.

if(all(x in accepted_columns for x in columns)):
>> if(status == false)
>>>> msg = {'Message' : true }
>>>> return make_response(jsonify(msg), 200)

So, what do you say?
@dlebauer @KristinaRiemer @saurabh1969 @Chris-Schnaufer

Remove responsive navbar ...

This is not needed b/c

  1. people won't be using this on mobile.
  2. navbar not needed (this is a form / workflow UI not a navagable website)

Why isn't this display style part of the "Link" element CSS? The bar may change its elements spacing when the user clicks it & it may be better to start out with correct spacing.

Originally posted by @Chris-Schnaufer in #50 (comment)

Set up github actions

  • super linter
  • tests for python and js
  • code coverage (eg codecov or sonarcube)
    • PR requires code coverage to stay the same or increase

Create GSOC roadmap

Put together list of deliverables and specific tasks in a new OSF page for the first deadline

Review swaggerhub specification

@kimberlyh66 please

Remove duplicate input files

We are going to merge #5. Then we can refactor to combine the contents of input_files and yaba_test/input_files, which are duplicates

Not able to insert sites table properly

Actually, when I was inserting sites table using the client route,

curl -F "fileName=@input_files/sites.csv" \
-F "shp_file=@input_files/S8_two_row_polys.shp" \
-F "dbf_file=@input_files/S8_two_row_polys.dbf" \
-F "prj_file=@input_files/S8_two_row_polys.prj" \
-F "shx_file=@input_files/S8_two_row_polys.shx" \
http://localhost:6001/sites

the app returned the response 410 and logged this error,

ERROR:root:Traceback (most recent call last):
yaba_api_1 | File "fiona/_shim.pyx", line 74, in fiona._shim.gdal_open_vector
yaba_api_1 | File "fiona/_err.pyx", line 270, in fiona._err.exc_wrap_pointer
yaba_api_1 | fiona._err.CPLE_OpenFailedError: '/code/temp/shp_file' not recognized as a supported file format.
yaba_api_1 |
yaba_api_1 | During handling of the above exception, another exception occurred:
yaba_api_1 |
yaba_api_1 | Traceback (most recent call last):
yaba_api_1 | File "/code/Meta.py", line 132, in insert_sites
yaba_api_1 | data_g1=gpd.read_file(shp_file_target)
yaba_api_1 | File "/usr/local/lib/python3.7/site-packages/geopandas/io/file.py", line 77, in read_file
yaba_api_1 | with reader(path_or_bytes, **kwargs) as features:
yaba_api_1 | File "/usr/local/lib/python3.7/site-packages/fiona/env.py", line 398, in wrapper
yaba_api_1 | return f(*args, **kwargs)
yaba_api_1 | File "/usr/local/lib/python3.7/site-packages/fiona/__init__.py", line 254, in open
yaba_api_1 | layer=layer, enabled_drivers=enabled_drivers, **kwargs)
yaba_api_1 | File "/usr/local/lib/python3.7/site-packages/fiona/collection.py", line 154, in __init__
yaba_api_1 | self.session.start(self, **kwargs)
yaba_api_1 | File "fiona/ogrext.pyx", line 484, in fiona.ogrext.Session.start
yaba_api_1 | File "fiona/_shim.pyx", line 81, in fiona._shim.gdal_open_vector
yaba_api_1 | fiona.errors.DriverError: '/code/temp/shp_file' not recognized as a supported file format.

But when I use the yaba_api route for inserting sites table,

curl -F "fileName=@input_files/sites.csv" \
-F "shp_file=@input_files/S8_two_row_polys.shp" \
-F "dbf_file=@input_files/S8_two_row_polys.dbf" \
-F "prj_file=@input_files/S8_two_row_polys.prj" \
-F "shx_file=@input_files/S8_two_row_polys.shx" \
http://localhost:5001/yaba/v1/sites

it succeeded in doing so. Also, when I am making a request using the browser, both routes log the same error. Don't know what is causing this.

@Chris-Schnaufer @saurabh1969 @dlebauer @KristinaRiemer

Setting up the Tests and Documentation

  • Set up TravisCI
  • Writing unit tests for YABA Flask api.
    • for sample data at each endpoint

Completion criteria:

  • Commit with .travis.yml
  • Sample data uploaded for testing
  • also merge sample data and test data #11

Implement testing as a matrix

For GitHub actions, can you use a matrix for testing the app, interface, etc. folders? It's easier to maintain a single YAML file than multiples of the same with minor variations.

https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix

The idea was to see if matrix could be used to combine the two Python tests into one file. I feel that putting Python and Node tests into the same file defeats simplification. If putting the Python app-test and client-tests into the same file using matrix makes things less simple, then that shouldn't be done.

Originally posted by @Chris-Schnaufer in #63 (comment)

Design and Implement Web UI and end user validation

Draft design documents from: #1

Note that these are a very crude approximation of the core functionality. We can discuss design, layout, content in the review.

Welcome

welcome_screen

Upload

upload

Upload Error Page

error_page

Validation / Review Page

validation

Upload Successful

upload_successful

@saurabh1969 please describe and work done to date and put in a feature branch

Create a validation/review page for users to validate data before upload

A proposed validation / review page. The goal of this is to make sure that the person uploading the metadata has a chance to confirm that the metadata they are uploading is correct / consistent with how they think it should be It can look like this:

image

Overview -

  • Use psql transactions to validate data with the backend (start session w/ begin and end with commit or rollback)
  • the position of each rectangle is defined by the geometry field in the shapefile - these will go into the sites.geometry field
    • for the first plot you can get the cultivars for each plot through a many-to-many join with sites thus: select name as cultivar, sitename as plot from cultivars join sites_cultivars on cultivars.id = sites_cultivars.cultivar_id join sites on sites_cultivars.site_id = sites.id
    • for the next two plots you can find experiments for each site through the experiments_sites table, and treatments through the experiments_treatments table
  • Use Leaflet to visualize
    • you can use shapefile extension
    • later it might be better to convert shapefile to geojson that leaflet handles natively.

Bonus: (can create a new issue for this): a page overlaying plots on a satellite or drone imagery to confirm the correct positions in space.

Set up development environment

Set up the environment for development using node js, create-react-app module.

This should be documented in README so that someone else can quickly get the application up and running

Implement Pylint rules for the Python codebase

The aim of this issue is to make the python codebase follow all standard rules by a linter. Right now, some warnings are ignored in the pylintrc file, make the codebase follow all these standard rules. This will make the YABA app better.

Actually, there were a lot of warnings for inconsistent-return-statements, missing-module-docstring and somehow Pylint action treats them as an error, not warning and so it fails the test for linting.

Originally posted by @im-prakher in #63 (comment)

Validate user-input API key

After the API key is entered in the Welcome page, it should be validated (#18)

  • check that API key is valid
    • select count(*) from users where apikey = $user_provided_apikey should return 1
  • confirm that user name. Display the name returned by the following query:
    • `select name from users where apikey = $user_provided_apikey

Implementing Python Client Library

Implement functions in Python (like R package) that enable use of the YABA API (unlike the existing R package, this will use the API rather than ODBC database connection).This will be used for both scripted workflows and as a backend to the UI.

Completion criteria:

  • Commit with client.py
  • Integration with UI.

Update documentation

This should go in

  • the YABA repo's README
  • the BETYdb docs.
  • These docs should be referenced in the PEcAn API documentation

User content:

  • Link to interface
  • Description/screenshots of data tables/shapefiles (see #54), point out example data

Developer content:

  • Endpoints
  • How to deploy interface

Set env variables in docker-compose to be used with interface and visualization parts of the app

Would it make sense to set environment variables here that reference the other YABA server addresses that can be accessed through ReactJS's process.env? This way only one place needs to change if the server information changes

Originally posted by @Chris-Schnaufer in #69 (comment)

The aim of this issue is to set port and host environment variables for the interface and visualization part in the docker-compose file itself so that can be used in these parts through ReactJS's and Node.js process.env

For reference- Reading an environment variable in react which was set by docker

Fix metadata upload API

There are currently two issues:

  1. In credentials.yaml, the PGHOST setting varies depending on the user's IP and breaks (at least on Macs) when set as localhost
  2. The sites table endpoint is not working

@Chris-Schnaufer might be able to help @saurabh1969 troubleshoot #1?

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.