Skip to content

Commit 0f3b641

Browse files
authored
Merge pull request #90 from guzman-raphael/disable-deep-dependency
Disable deep dependency and update NGINX image
2 parents 19db7c1 + f9cfdbc commit 0f3b641

File tree

6 files changed

+11
-55
lines changed

6 files changed

+11
-55
lines changed

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
44

5-
## [Unreleased]
5+
## [0.1.0b0] - 2021-02-26
66

7-
## Security
7+
### Security
88
- Documentation with detail regarding warning on bearer token. (#83) PR #88
99

10-
## Fixed
10+
### Fixed
1111
- Incorrect virtual module reference of `schema_virtual_module` in table metadata. (#85) PR #88
1212

1313
### Added
@@ -20,6 +20,8 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
2020
- Replaced `DJConnector.snake_to_camel_case` usage with `datajoint.utils.to_camel_case`. PR #88
2121
- Default behavior for `/delete_tuple` now deletes without cascading. (#86) PR #88
2222
- Consolidated `pytest` fixtures into `__init__.py` to facilitate reuse. PR #88
23+
- Modify dependency check to not perform deep check and use accessible fk relations only. (#89) PR #90
24+
- Update nginx image to pull from datajoint organization. (#80) PR #90
2325

2426
### Removed
2527
- Docker `base` environment to simplify dependencies. PR #79
@@ -34,5 +36,5 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
3436
- Support for DataJoint attribute types: `varchar`, `int`, `float`, `datetime`, `date`, `time`, `decimal`, `uuid`.
3537
- Check dependency utility to determine child table references.
3638

37-
[Unreleased]: https://github.com/datajoint/pharus/compare/0.1.0a5...HEAD
39+
[0.1.0b0]: https://github.com/datajoint/pharus/compare/0.1.0a5...0.1.0b0
3840
[0.1.0a5]: https://github.com/datajoint/pharus/releases/tag/0.1.0a5

docker-compose-deploy.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# PHARUS_VERSION=0.1.0a5 docker-compose -f docker-compose-deploy.yaml pull
2-
# PHARUS_VERSION=0.1.0a5 docker-compose -f docker-compose-deploy.yaml up -d
1+
# PHARUS_VERSION=0.1.0b0 docker-compose -f docker-compose-deploy.yaml pull
2+
# PHARUS_VERSION=0.1.0b0 docker-compose -f docker-compose-deploy.yaml up -d
33
#
44
# Intended for production deployment.
55
# Note: You must run both commands above for minimal outage
@@ -20,7 +20,7 @@ services:
2020
# - PHARUS_PREFIX=/
2121
fakeservices.datajoint.io:
2222
<<: *net
23-
image: raphaelguzman/nginx:v0.0.15
23+
image: datajoint/nginx:v0.0.15
2424
environment:
2525
- ADD_pharus_TYPE=REST
2626
- ADD_pharus_ENDPOINT=pharus:5000

docker-compose-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ services:
2323
command: pharus
2424
fakeservices.datajoint.io:
2525
<<: *net
26-
image: raphaelguzman/nginx:v0.0.15
26+
image: datajoint/nginx:v0.0.15
2727
environment:
2828
- ADD_pharus_TYPE=REST
2929
- ADD_pharus_ENDPOINT=pharus:5000

pharus/interface.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
import datetime
55
import numpy as np
66
from functools import reduce
7-
from datajoint.errors import AccessError
8-
import re
97
from .error import InvalidDeleteRequest, InvalidRestriction, UnsupportedTableType
108

119
DAY = 24 * 60 * 60
1210
DEFAULT_FETCH_LIMIT = 1000 # Stop gap measure to deal with super large tables
13-
TABLE_INFO_REGEX = re.compile(
14-
r'.*?FROM\s+`(?P<schema>\w+)`.*?name\s*?=\s*?"(?P<table>.*?)".*?')
1511

1612

1713
class DJConnector():
@@ -312,16 +308,6 @@ def record_dependency(jwt_payload: dict, schema_name: str, table_name: str,
312308
dependencies = [dict(schema=descendant.database, table=descendant.table_name,
313309
accessible=True, count=len(descendant & primary_restriction))
314310
for descendant in table().descendants(as_objects=True)]
315-
# Determine first issue regarding access
316-
# Start transaction, try to delete, catch first occurrence, rollback
317-
virtual_module.schema.connection.start_transaction()
318-
try:
319-
(table & primary_restriction).delete(safemode=False, transaction=False)
320-
except AccessError as errors:
321-
dependencies = dependencies + [dict(TABLE_INFO_REGEX.match(
322-
errors.args[2]).groupdict(), accessible=False)]
323-
finally:
324-
virtual_module.schema.connection.cancel_transaction()
325311
return dependencies
326312

327313
@staticmethod

pharus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Package metadata."""
2-
__version__ = '0.1.0a5'
2+
__version__ = '0.1.0b0'

tests/test_dependencies.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,6 @@
33
from . import SCHEMA_PREFIX, client, token, group1_token, connection, schemas_simple
44

55

6-
def test_dependencies_underprivileged(group1_token, client, schemas_simple):
7-
schema_name = f'{SCHEMA_PREFIX}group1_simple'
8-
table_name = 'TableA'
9-
restriction = b64encode(dumps(dict(a_id=0)).encode('utf-8')).decode('utf-8')
10-
REST_dependencies = client.get(
11-
f"""/record/dependency?schemaName={
12-
schema_name}&tableName={table_name}&restriction={restriction}""",
13-
headers=dict(Authorization=f'Bearer {group1_token}')).json['dependencies']
14-
REST_records = client.post('/fetch_tuples',
15-
headers=dict(Authorization=f'Bearer {group1_token}'),
16-
json=dict(schemaName=schema_name,
17-
tableName=table_name)).json['tuples']
18-
assert len(REST_records) == 2
19-
assert len(REST_dependencies) == 4
20-
table_a = [el for el in REST_dependencies
21-
if (el['schema'] == f'{SCHEMA_PREFIX}group1_simple' and
22-
'table_a' in el['table'])][0]
23-
assert table_a['accessible'] and table_a['count'] == 1
24-
table_b = [el for el in REST_dependencies
25-
if (el['schema'] == f'{SCHEMA_PREFIX}group1_simple' and
26-
'table_b' in el['table'])][0]
27-
assert table_b['accessible'] and table_b['count'] == 2
28-
table_c = [el for el in REST_dependencies
29-
if (el['schema'] == f'{SCHEMA_PREFIX}group1_simple' and
30-
'table_c' in el['table'])][0]
31-
assert table_c['accessible'] and table_c['count'] == 3
32-
diff_table_b = [el for el in REST_dependencies
33-
if (el['schema'] == f'{SCHEMA_PREFIX}group2_simple' and
34-
'diff_table_b' in el['table'])][0]
35-
assert not diff_table_b['accessible']
36-
37-
386
def test_dependencies_admin(token, client, schemas_simple):
397
schema_name = f'{SCHEMA_PREFIX}group1_simple'
408
table_name = 'TableA'

0 commit comments

Comments
 (0)