Skip to content

Commit a29cf56

Browse files
committed
first commit
0 parents  commit a29cf56

18 files changed

Lines changed: 588 additions & 0 deletions

.gitignore

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
.terraform
6+
terraform.tfstate
7+
terraform.tfstate.backup
8+
.secrets
9+
node/.secrets
10+
examples/real/*
11+
node/*.pem
12+
13+
# C extensions
14+
*.so
15+
.DS_Store
16+
.clusters
17+
# Distribution / packaging
18+
.Python
19+
build/
20+
develop-eggs/
21+
dist/
22+
downloads/
23+
eggs/
24+
.eggs/
25+
lib/
26+
lib64/
27+
parts/
28+
sdist/
29+
var/
30+
wheels/
31+
*.egg-info/
32+
.installed.cfg
33+
*.egg
34+
MANIFEST
35+
36+
hyper/cluster/terraform/asg/.ssh/
37+
hyper/cluster/terraform/asg/terraform.tfstate
38+
hyper/cluster/terraform/asg/terraform.tfstate.backup
39+
40+
.kube
41+
42+
# PyInstaller
43+
# Usually these files are written by a python script from a template
44+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
45+
*.manifest
46+
*.spec
47+
48+
# Installer logs
49+
pip-log.txt
50+
pip-delete-this-directory.txt
51+
52+
# Unit test / coverage reports
53+
htmlcov/
54+
.tox/
55+
.coverage
56+
.coverage.*
57+
.cache
58+
nosetests.xml
59+
coverage.xml
60+
*.cover
61+
.hypothesis/
62+
.pytest_cache/
63+
64+
# Translations
65+
*.mo
66+
*.pot
67+
68+
# Django stuff:
69+
*.log
70+
local_settings.py
71+
db.sqlite3
72+
73+
# Flask stuff:
74+
instance/
75+
.webassets-cache
76+
77+
# Scrapy stuff:
78+
.scrapy
79+
80+
# Sphinx documentation
81+
docs/_build/
82+
83+
# PyBuilder
84+
target/
85+
86+
# Jupyter Notebook
87+
.ipynb_checkpoints
88+
89+
# pyenv
90+
.python-version
91+
92+
# celery beat schedule file
93+
celerybeat-schedule
94+
95+
# SageMath parsed files
96+
*.sage.py
97+
98+
# Environments
99+
.env
100+
.venv
101+
env/
102+
venv/
103+
ENV/
104+
env.bak/
105+
venv.bak/
106+
107+
# Spyder project settings
108+
.spyderproject
109+
.spyproject
110+
111+
# Rope project settings
112+
.ropeproject
113+
114+
# mkdocs documentation
115+
/site
116+
117+
# mypy
118+
.mypy_cache/
119+
120+
hyper.sublime-*
121+
.kube-temp
122+
123+
hyper_search/
124+
yolo/
125+
logs/

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from python:3
2+
ADD ./ /workspace
3+
RUN pip install -e /workspace

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Meta arrays
2+
3+
Minimum viable product
4+
5+
1. Setup
6+
Install, then provide AWS credentials and bucket name
7+
```sh
8+
pip3 install -e .
9+
meta configure
10+
```
11+
12+
2. Create an array
13+
```python
14+
mnist = meta.array((50000, 28, 28, 1), name="username/mnist:v1", dtype='float32')
15+
mnist[0, :] = np.random.random((1, 28, 28, 1)).astype('float32')
16+
```
17+
18+
3. Load an array
19+
```python
20+
mnist = meta.load(name='username/mnist:v1')
21+
print(mnist[0,0,0,0])
22+
```

docker-compose.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '2'
2+
3+
services:
4+
meta:
5+
build:
6+
context: .
7+
volumes:
8+
- ./:/workspace/
9+
command: bash -c "
10+
cd /workspace
11+
&& meta configure
12+
&& python3 example.py"
13+
prod:
14+
image: python:3
15+
volumes:
16+
- ./:/workspace/
17+
command: bash -c "
18+
cd /workspace
19+
&& ls
20+
&& pip3 install meta-array-beta
21+
&& meta configure"

example.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import meta
2+
import numpy as np
3+
4+
vol = meta.load(name='imagenet/image:val')[400:600]
5+
a = (vol.mean(axis=(1,2,3)) == 0).sum()
6+
print(vol.mean(axis=(1,2,3)) == 0)
7+
exit()
8+
# Currently only support for up to 4D images
9+
mnist = meta.array((50000, 28, 28, 1), name="jason/mnist:v2", dtype='float32')
10+
mnist[0, :] = np.random.random((1, 28, 28, 1)).astype('float32')
11+
12+
#mnist[0,:,:,:] = np.random.random((1,100,1)).astype('float32')
13+
#print(mnist[0])
14+
#print(mnist.dtype)
15+
16+
17+
print(mnist[0,0,0,0])
18+
# TODO load
19+
mnist = meta.load(name='jason/mnist:v1')
20+
21+
print(mnist[0].shape)
22+
print(mnist[0,0,0,0])
23+
#print(mnist[0,:].shape)
24+
25+
# - Upload ImageNet (Read only)
26+
27+
28+

meta/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import meta
2+
from meta.marray.array import array, load
3+
import click
4+
import sys
5+
from meta.log import configure_logger
6+
from .cli.auth import configure
7+
8+
@click.group()
9+
@click.option('-v', '--verbose', count=True, help='Devel debugging')
10+
def cli(verbose):
11+
configure_logger(verbose)
12+
13+
def add_commands(cli):
14+
cli.add_command(configure)
15+
16+
add_commands(cli)

meta/cli/__init__.py

Whitespace-only changes.

meta/cli/auth.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import click
2+
from meta.log import logger
3+
from meta.utils.store_control import StoreControlClient
4+
from meta.utils.verify import Verify
5+
6+
@click.command()
7+
@click.option('--username', '-u', default=None, help='Your AWS access key')
8+
@click.option('--password', '-p', default=None, help='Your AWS secret key')
9+
@click.option('--bucket', '-b', default=None, help='Desired bucket name')
10+
def configure(username, password, bucket):
11+
""" Logs in to Meta"""
12+
logger.info("Please log in using your AWS credentials.")
13+
if not username:
14+
logger.debug("Prompting for Access Key")
15+
username = click.prompt('AWS Access Key ID', type=str, hide_input=False)
16+
access_key = username.strip()
17+
18+
if not password:
19+
logger.debug("Prompting for Secret Key")
20+
password = click.prompt('AWS Secret Access Key', type=str, hide_input=False)
21+
secret_key = password.strip()
22+
23+
if not bucket:
24+
logger.debug("Prompting for bucket name")
25+
bucket = click.prompt('Bucket Name (e.g. company-name)', type=str, hide_input=False)
26+
bucket = bucket.strip()
27+
28+
success, creds = Verify(access_key, secret_key).verify_aws(bucket)
29+
if success:
30+
StoreControlClient().save_config(creds)
31+
logger.info("Login Successful.")
32+
else:
33+
logger.error("Login error, please try again")
34+
35+
def logout():
36+
""" Logs out of Snark AI"""
37+
# TODO remove scripts
38+
TokenManager.purge_token()

meta/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
3+
curr_path = os.path.dirname(os.path.abspath(__file__))
4+
5+
TOKEN_FILE_PATH = os.path.expanduser("~/.meta/token")
6+
CLOUDVOLUME_PATH = os.path.expanduser("~/.cloudvolume/secrets/aws-secret.json")

meta/log.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import logging
2+
import sys
3+
4+
logger = logging.getLogger('meta')
5+
def configure_logger(debug):
6+
log_level = logging.DEBUG if debug == 1 else logging.INFO
7+
logging.basicConfig(format='%(message)s',
8+
level=log_level,
9+
stream=sys.stdout)
10+

0 commit comments

Comments
 (0)