Skip to content

Installation

JHaller27 edited this page Apr 18, 2019 · 12 revisions

MongoDB Installation

If you are using a locally hosted MongoDB server, check out the official installation and run guide and follow the guide for your operating system.

Alternatively, you can use MongoDB Atlas for a cloud-hosted database (just keep in mind that the free servers are great for testing things, but likely do not have the storage capacity required for use with AstroDB).

Finally, MongoDB Compass is the official tool for browsing a MongoDB database. It works with either locally hosted or remote instances.

AstroDB Installation

First, make sure you've downloaded or cloned this repository.

Easy Installation

Run the command astrodb$ . setup in the terminal.

If you already have MongoDB installed, then you're done! Move on to Usage for information on how to use AstroDB.

DIY Installation

Before you install, there's one important consideration: virtual environment or global environment? This guide will lead you through the virtual environment setup, but should also give you the information you need to setup your own global environment if you so choose.

Why Virtual Environment?

A python virtual environment ("venv") ensures the project's dependencies and requirements are managed separate from those of other projects.

Consider this scenario: the AstroPy python module is an important part of AstroDB. If AstroPy updates something important (such as the name of a particular function), what happens? Well, nothing happens until you update your AstroPy installation. In this hypothetical scenario, you've been using AstroDB for a couple years but you find another tool that does some other neat trick! Thing is, this other tool also requires AstroPy, but the newest version. Since the function name that changed is used in AstroDB, it now no longer works. Only the new version of AstroPy works with the other tool, but only the older version works with AstroDB and you really don't feel like updating AstroDB. You're now stuck.

In the above scenario, if AstroDB had its own venv (and the "other tool" could/should also have its own venv), then all of its requirements would be kept separate. So even if AstroPy needed to be updated in a way that would break AstroDB, the venv would keep that update completely separate from AstroDB. Or vice-versa, if AstroDB requires a newer version of a module which would break a tool you already have, a venv prevents your AstroDB installation from affecting other tools and their dependencies.

Actual Installation

It's assumed that AstroDB will be installed on Linux (tested on Ubuntu 18.04) using the terminal.

  1. Clone or download this repository.
  2. From the cloned/downloaded directory, run the following commands...
    • astrodb$ python3.7 -m venv venv
      • This creates the virtual environment, and sets it up to use Python3.7.
    • astrodb$ ln -s venv/bin/activate activate
      • This creates a handy shortcut to the script used to activate the venv.
    • astrodb$ . activate
      • This actually activates the venv. Warning: While the venv is activated, your terminal will act like the default python version is 3.7 rather than 2.0, and the only "installed" modules are those required for AstroDB.
    • astrodb$ pip install -r requirements.txt
      • This installs all python modules needed to run AstroDB tools.
      • If not using a venv, run ONLY this command as $ pip3 install -r requirements.txt
    • Or if you're lazy, instead run astrodb$ python3.7 -m venv venv && ln -s venv/bin/activate activate && . activate && pip install -r requirements.txt
      • This will run all of the above commands, but stop if any command encounters an error.
      • Do not run this command if you have already run the previous commands. It probably isn't a problem, but I'm still going to label it as "undefined behavior".
  3. Run AstroDB scripts with astrodb/src$ python <filename>.py (or with astrodb/src$ python3.7 <filename>.py if not using a venv). For more detailed usage information, see wiki/Usage