Skip to content

Make hands-on Colab friendly #2

Open

Description

@m09
No description provided.

Activity

  1. m09 commented on Jan 24, 2020

    @m09
    ContributorAuthor

    After more deliberation, the target to achieve is: no external dependency, or as few as possible.

    Every dependency should be installed in the docker image. For Colab, a special cell at the start of the notebook should contain the installation part. To make sure it runs only on Colab, it's possible to use:

    try:
        import google.colab
        # do stuff
    except:
        pass
  2. m09 commented on Jan 28, 2020

    @m09
    ContributorAuthor

    I isolated the dependencies in separate scripts so that they can be installed in one line in Colab. Proposed setup cell is now:

    try:
      import google.colab
      from os import environ
      is_git_dir = !git rev-parse --is-inside-work-tree
      if not is_git_dir:
        !git init
        !git remote add origin https://github.com/mloncode/workshop.git
      !git fetch origin master
      !git reset --hard origin/master
      # !./scripts/install-bigartm
      # !./scripts/install-tree-sitter
      # !./scripts/install-nltk-data
      # !pip install -r conf/requirements-setup.txt
      # !pip install -r conf/requirements.txt
      # environ["SOME_ENV_VAR"] = "some_value"
    except:
      # Not on Colab, environment is handled separately
      pass

    Last step will probably be to split the requirements even further on a per-notebook basis to install only the minimum env for each notebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions