Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add first round of pgtools #642

Merged
merged 17 commits into from
Apr 24, 2019
Merged

add first round of pgtools #642

merged 17 commits into from
Apr 24, 2019

Conversation

bgruening
Copy link
Owner

This will use a in-user-space postgresql version and can load schemas into it and query the db. Many more tools will be added in the future. Open for comments.

Copy link
Collaborator

@hexylena hexylena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOVE IT.

</token>

<token name="@ARCHIVE_DATABASE@"><![CDATA[
tar -cvJf postgresql_out.tar.xz ./postgresql
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the html extra files path thing to avoid the overhead of tarring / un-tarring.

Copy link
Collaborator

@hexylena hexylena Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retracted: out of band discussion concluded that disk space was more important than the computational overhead.


<token name="@PG_START@"><![CDATA[
'$__tool_directory__/pglite' start -d ./postgresql &&
sleep 10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly worried about this. Wonder if we could switch a while loop?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could put the sleep in a while look and ask if the server is available? Not sure what the best way is here. Maybe we could make this start command blocking?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love a sleep in a while. Maybe something like the following would be good so we'd be safe from sleeping too much or too little, and we can be sure we won't sleep forever if something goes wrong.

exec_count=0
'$__tool_directory__/pglite' status | grep -F -q 'server is running'
while [ $? -ne 0 ]; do
    sleep 2
    exec_count=$((exec_count+1))
    if [[ "$exec_count" -gt 10 ]]; then exit 1; fi
    '$__tool_directory__/pglite' status | grep -F -q 'server is running'
done

(Completely untested.)

Copy link
Owner Author

@bgruening bgruening Oct 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used unless ... status still does not work reliably, but checking for the socket file in addition does the trick.

@@ -0,0 +1,48 @@
<tool id="pg_query" name="Postgresql" version="@PG_VERSION@">
<description>import sql dump</description>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description

Copy link
Owner Author

@bgruening bgruening Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? I don't see it :(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change description from "import sql dump" to something like "query postgres database"

<param format="postgresql" name="infile" type="data" label="Input database" />
<param name="query" type="text" area="True" size="5x50" label="The query to be issued to the database">
<sanitizer>
<valid initial="string.letters,string.digits">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this won't be enough, we'll need ' at least.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, other can be at any time.

@PG_START@ &&
ls -l ./postgresql
&&
@PSQL@ -c '$query' -L logfile.log > '$outfile' &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we wrap this in a copy ($query) to stdout with csv delimiter ' '; (i.e. raw tab char)? Then you'd get automatic tabular files. (or at least make it an option and make tab output default)

@bgruening
Copy link
Owner Author

I added a new test and addressed your other concerns, besides the sleep thing.


######################### Delegates to subcommands or runs main, as appropriate

main "$@"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to document the license / source+license for this script somewhere, i.e. https://github.com/solidsnack/pglite/blob/master/LICENSE

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should ship this tool at all, we should rather depend on it.

Copy link
Collaborator

@hexylena hexylena Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me! (But we still need to either remove the script or add the license header)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this file and we now depend on a conda package

@bgruening
Copy link
Owner Author

So tests are passing. Its a start I guess ...

</token>

<token name="@STATUS_RUNNING@"><![CDATA[
timeout 30 bash -c 'until pglite status -d ./postgresql | grep -F -q "server is running"; do sleep 1; done' &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fyi, the reason for my horribly long while loop was that timeout is unavailable on OSX. Not sure if we care about those guys (I don't really that much.)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care that much either and doubt that anyone one is running a server under OSX.
I think this is ready to go for a first version.

@bgruening
Copy link
Owner Author

Like the additional tool!

@yvanlebras
Copy link

Ready to start things on a postgis version with @ValentinChCloud and @Alanamosse for Galaxy-E!

@bgruening
Copy link
Owner Author

@yvanlebras awesome. Let me know if these tools work for you and what I can do to improve it.
One other requirement would be a postgresql-gis conda package :)

@yvanlebras
Copy link

Have you a postgresql datatype definition already ?

@hexylena
Copy link
Collaborator

@yvanlebras
Copy link

Thanks @erasche ! I missed it ! Nice end of week.

@bgruening
Copy link
Owner Author

Ok, let's get this in. I'm currently trying to ship with a GIS and rdkit enabled PG version, but this can also be an update.

Thanks everyone!

ping @abretaud

@bgruening
Copy link
Owner Author

ping @annefou, this might be interesting for you as well. It can use GIS-enabled postgresql databases in user-space. You can treat a PG database like any other Galaxy database.

@yvanlebras
Copy link

This is something we have to work on. Maybe it's time to go further and try to test creating a qgis 3 interactive took!

@annefou
Copy link

annefou commented Jul 19, 2020

This is something we have to work on. Maybe it's time to go further and try to test creating a qgis 3 interactive took!

Yes. We can discuss it during the co-fest?!

@bgruening
Copy link
Owner Author

Sure :)

@yvanlebras
Copy link

Yes! Very good idea Anne. I will try to have some GIS colleagues, maybe you have this ?

@annefou
Copy link

annefou commented Jul 19, 2020

Yes we use arcGIS a lot but more and more QGIS too. We have dockerized versions of QGIS desktop that could be added to Galaxy. I am not sure what is best so we can discuss it during the co-fest!

@yvanlebras
Copy link

I was notably thinking about something like thishttps://github.com/jancelin/geo-poppy

@bgruening bgruening mentioned this pull request Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants