-
Notifications
You must be signed in to change notification settings - Fork 33
Processing-Server #974
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
Merged
Merged
Processing-Server #974
Changes from all commits
Commits
Show all changes
230 commits
Select commit
Hold shift + click to select a range
f2cf4e6
prototype for processing broker
joschrew 2a4919c
refactoring: try to make it easier to read
joschrew d23bb3c
adapt code to changed config-file
joschrew 7e20fef
change config representation class
joschrew d5a8641
add config validation
joschrew fd8e724
add deployment with docker-sdk
joschrew 8f0796d
deploy queue and mongodb with docker-sdk
joschrew 65dc60f
refactor code
joschrew ad8acc6
Add the required dependencies
MehmedGIT 55ba0e4
Make queue and db deploy more flexible
MehmedGIT 22bc5de
Refactor deployment of processors
MehmedGIT efdc5da
Conceptual integration of the RabbitMQ library
MehmedGIT 1724662
Refactor: separate deplyoer from deployment utils
MehmedGIT 16bcb4b
Refactor processing broker/worker
MehmedGIT 9901f90
Revert requirements.txt to keep track of future conflicting files
MehmedGIT 0ce527b
Merge remote-tracking branch 'origin/master' into dev-processing-broker
MehmedGIT 86979f2
Extend requirements
MehmedGIT 07b1733
Adopt useful methods
MehmedGIT 6639c79
Create network package by refactoring
MehmedGIT 76c40a3
Add example broker configuration
MehmedGIT 3e4e76c
Change logger names
joschrew f1c27f3
Replace double quoted strings with single quoted
joschrew 4fcaeb5
Add typehints for network files
joschrew d700522
Add address-option to processing broker
joschrew 019e94e
Remove informational non-code files again
joschrew 36160cc
Change functionsignature docker/ssh clientcreation
joschrew 23b0db9
Remove (not working) close_clients function
joschrew f218669
Move, rename and modify config-classes
joschrew 078fa31
Change enum value comparision for deploy_type
joschrew 4f8d700
Improve for loops over processors
joschrew 6b549f1
Remove and change some asserts
joschrew f5ad740
Add a few explanatory comments
joschrew 02e3c4c
Change and and comments
joschrew fde789a
Change config file validation and handling
joschrew ab74eec
refactor: port -> ports_mapping
MehmedGIT edaf55d
refactor: _queue -> _rabbitmq
MehmedGIT 87a83a8
Fix typo in kill_processing_workers
MehmedGIT e82de10
Implement kill_processing_worker separately
MehmedGIT 612dc0b
Improve comments and checks
MehmedGIT 76825fc
Add processing worker cli template
MehmedGIT 8c60172
Copy RabbitMQ utility library from the WebAPI impl repo
MehmedGIT 736a606
Add the reference note to the RabbitMQ utils
MehmedGIT 1ec9371
Use actual RMQConsumer inside the processing_worker
MehmedGIT 51690ee
Use actual RMQPublisher inside the processing_broker
MehmedGIT af5c0b4
Refactor and optimize imports
MehmedGIT fb213e8
Fix imports in rabbitmq_utils, add pika as a requirement
MehmedGIT 41defe3
Remove config file and tomli as a requirement
MehmedGIT 03c0946
Refactor defaults in rabbitmq_utils webapi->network
MehmedGIT ca1b1b9
Comment out RabbitMQ publisher/consumer
MehmedGIT 49089c7
Improve deploy/kill order
MehmedGIT 346bb2c
Split configurations for better readability
MehmedGIT 1a290a2
Remove typing which was auto added by the IDE
MehmedGIT 1453b74
change scope of get_processor
MehmedGIT 2933a06
Move methods from Processing Worker to Deployer
MehmedGIT 3300391
Refactor name -> processor_name
MehmedGIT 9a7641b
Finish transfering of methods from Worker to Deployer
MehmedGIT a059f1c
Improve the template of processing worker
MehmedGIT 29c30e5
Import the job and tool models from prev implementation
MehmedGIT 908b118
Add processing worker wrappers for run_cli and run_processor
MehmedGIT 680b706
Fix import of ocrd_messages
MehmedGIT 9de2175
RabbitMQ and MongoDB addr handling helpers
MehmedGIT a2481bd
Add helpers for addr parsing
MehmedGIT c83fec9
Extend decorators to accept --queue and --database
MehmedGIT 1d8c1b0
Extend processing worker
MehmedGIT 62ae01b
Remove default values for --queue and --database
MehmedGIT eeb797b
Increase sleep command of the dummy docker container
MehmedGIT fd24c4f
Fix rabbitmq path in logging of processing_worker
MehmedGIT 6359bdf
Refactor processing broker + activate queue creation
MehmedGIT ef34e67
Log messages received from the Management UI on port 15672
MehmedGIT cfcc036
Improve logging + add some TODOs and remarks
MehmedGIT 3bd6f70
Retrieve ocrd_tool by using util method
MehmedGIT 7138979
Force logging settings - paramiko=INFO, ocrd.network=DEBUG
MehmedGIT 0f826fd
Implement on_consumed_message method
MehmedGIT 2a5d442
default message constructing methods
MehmedGIT 7912ae3
Append default global vhost, when not provided
MehmedGIT fb11953
database prefix should be passed as an argument
MehmedGIT e93d702
Fix --queue and --database, not flags
MehmedGIT 952e6e9
Add remarks about start_*_processor methods
MehmedGIT 43050ab
Provide a basic testing endpoint to processing broker (aka server)
MehmedGIT ae18c08
Make address param for processing broker required
joschrew fdfaf8d
Use credentials from config for rabbitmq messaging
joschrew f387f92
Add new parameters to processor help output
joschrew d35d006
Improve error message for processing worker
joschrew beca781
Insert credentials on rabbitmq startup
joschrew f2c3e6e
Change message exchange from pickle to str for now
joschrew 2f045b3
Change rabbitmq default credentials
joschrew d1c1f50
Add optional path_to_bin_dir to config and use it
joschrew 344e593
Add route to p-broker to start a p-worker
joschrew 77a316d
Add typehints for a method in processing_worker
joschrew e16e3d4
Replace double quoted strings with single quoted
joschrew 512ea77
Add missing typehints for network modules
joschrew e876cf9
Review (mainly comments for) CustomDockerClient
joschrew 59e8418
Remind myself to rename the broker
joschrew 5900c73
Reuse parts of older impl for running a processor
joschrew 2323fac
Add processor enpoints from previous impl (pr 884)
joschrew c57e75c
Change comments and format and do some cleanup
joschrew 868d58d
Adapt to latest config changes
joschrew 53e9b47
Use definitions.json for rabbitmq
joschrew 72a8e5c
Rename processing broker to processing server
joschrew 0f399ea
Set job state after worker finishes
joschrew 8143614
Add enpoint to list processors
joschrew 871323b
Remove redundant log output
joschrew 7f4f1d7
Ensure processor availability before processing
joschrew 1caffd6
Implement the result-queue logic - worker uses RMQPublisher
MehmedGIT a16aa02
Send encoded result message
MehmedGIT ab326f7
Add exception handler to debug validation
MehmedGIT 4368b53
Workers push finished job status to result queue
MehmedGIT e2452e4
Example NF script (still broken) executed by the WF Server to submit …
MehmedGIT de3b41a
Add workspace_id parameter to processor-call
joschrew 8b583d9
Add workspace model basically that from webapi
joschrew 5d218a1
Add workspace_id/path param-check to run_processor
joschrew 1142449
Resolve mets path with workspace id
joschrew be0fe51
Check off some trivial todos
joschrew 67753b1
Stop splitting config in ProcessingServer
joschrew 6a526af
Stop storing pid for queue and mongo in config
joschrew d9d959e
Separating config and data for hosts
joschrew f51b3b8
Removing unnecessary things after meeting with Jonas
MehmedGIT 30498a7
Add cleanup and exceptionhandling to startup
joschrew 6a3836d
Remove unnecessary loggging and clean comments
joschrew c838ed7
Add job response model
joschrew d763d4c
Add mechanism to ensure queue startup
joschrew 5b4e22d
Remove a few more unneeded todo-notes
joschrew f6fe1c3
Merge branch 'master' into dev-processing-broker
MehmedGIT 84acd77
Remove unnecessary parts
MehmedGIT b586f70
Add logging to file for processing workers
MehmedGIT 0bb9bdb
Wait 100ms between deployment of ocr-d processors
MehmedGIT ec9ffc6
Merge master
MehmedGIT 9ab1146
Dirty fix - disable interactive shell logging for calamari
MehmedGIT 6cd2a89
Enable instance caching for processors - tested and working
MehmedGIT 144f262
Add tensorflow to core requirements
MehmedGIT 6c3c6d5
Add changes from fix-972 branch
MehmedGIT cb54a67
Replace ocrd logging with python logging
MehmedGIT 5a328c2
Lower the scope of tf keras import
MehmedGIT c02f0ba
Revert logging back to ocrd logging in worker
MehmedGIT cef1d0d
Refactor imports, logging, spacing
MehmedGIT b73c899
Remove config-var path_to_bin_dir again
joschrew 3135a4b
Rearrange docker and ssh client creation
joschrew c00dc04
Fix copy paste mistake from last commit
joschrew bd3a6c2
Add workaround for rabbitmq startup on remote host
joschrew a1d5611
Remove the unnecessary rabbitmq.conf file
MehmedGIT de492b8
Rename table for workspace in mongo
joschrew 6c09711
Use config credentials for server and workers
MehmedGIT b264652
Create ocrd_network package
joschrew 826d9a0
Remove usage of definitions.json with rabbitmq
joschrew ad98e12
Fix dependency in requirements
MehmedGIT fffb7dc
Update doc for processing server
joschrew f5e45b3
Improve exception message
MehmedGIT 9829b18
Remove parsing of stdout in ocrd decorators
MehmedGIT b73e99a
Update processing worker cli help
MehmedGIT cf7321d
Update ocrd-network package info in __init__
MehmedGIT 132b93f
Update ocrd_network/ocrd_network/deployer.py info
MehmedGIT a2a7fe9
Change getcwd() call location
MehmedGIT 22311f1
Update ocrd_network/ocrd_network/deployer.py help
MehmedGIT f9c5414
Update ocrd_network/ocrd_network/deployer.py
MehmedGIT 4e66ed3
Raise the error instead of returning it
MehmedGIT d1f287d
Revert getcwd() location - failing tests
MehmedGIT ddc92d7
Fix set_job_state
MehmedGIT 75b5d4e
Make conditional TF import
MehmedGIT b3ada1f
Remove unused function
joschrew f154949
Implement custom type check
MehmedGIT 8a256d5
Change native processor startup output handling
joschrew e125a14
Fix uvicorn logging bug
joschrew b5d3496
Add possibility to run bashlib processors too
joschrew 5ff8860
Add module docstring for database
joschrew 2b5cc3b
parameters -> arguments in RMQ connector
MehmedGIT ad04cb6
Fix quotes
MehmedGIT 8e7b1f8
better error message
MehmedGIT 44e1eaa
Improve validation and parsing of URIs
MehmedGIT c791260
Clean, refactor, and add small TODOs
MehmedGIT 494c0ab
chdir to ws as in #987
MehmedGIT d784a75
Call getcwd before get_processor
MehmedGIT 43a5660
Set ws outside the constructor
MehmedGIT e396b2b
Modify OcrdResultMessage
MehmedGIT 57d4791
Move check before assignments
MehmedGIT 7288d6d
Remove pymongo, add call_sync wrapper
MehmedGIT 5e6d0ad
Refactor helpers -> utils
MehmedGIT 66851d4
Add callback_url, improve models
MehmedGIT 07828a6
Remove the debugging file
MehmedGIT 0eb74b9
Remove result queue related info logs
MehmedGIT da2e7e1
Initiate DB client after db addr verification
MehmedGIT 31d3a08
Improve exception message
MehmedGIT b82446c
refactor result_queue, callback_url checks
MehmedGIT 0f0a6d3
Set workspace_id when available
MehmedGIT 44b6b6e
minor variable and comment improvements
MehmedGIT 8e0d7d8
fix result queue related things
MehmedGIT d1e7ff9
path -> path_to_mets in Job
MehmedGIT c6be974
Fix job.path -> job.path_to_mets, refactor
MehmedGIT 4dd0ea9
Create job_id, don't rely on document_id
MehmedGIT 69399fb
Refactor status -> state to have same standard
MehmedGIT d1d85c6
Remove json.dumps
MehmedGIT 93b7f5b
Refactor the setup.py
MehmedGIT 8f32004
Big refactoring - use relative imports
MehmedGIT 3c3273b
Fix setup.py
MehmedGIT 32b935b
Merge master v2.48.0
MehmedGIT e080a0f
Refactor processing config validation
MehmedGIT 59a06ab
Validate processing message against message schema
MehmedGIT 787510e
Fix: catch db workspace exception
MehmedGIT 1679382
impove: match the returned http status code
MehmedGIT 709c46c
fix: resolve mets path in worker, not server
MehmedGIT 39840e2
fix: process job model
MehmedGIT 9ba05e0
db single update method
MehmedGIT 0fe51f2
calculate execution time in ms
MehmedGIT 9910482
resolve: suggestions by kba
MehmedGIT 4774f51
bashlib: implement Processing Worker args
bertsky 6741d55
improve generate_processor_help:
bertsky 0ccc963
ocrd_cli_options: remove redundant help kwarg
bertsky e2e6e69
start native cli: no need for is_bashlib_processor
bertsky 4ab2657
rm is_bashlib_processor
bertsky a4b9c96
rm Py36 test – no longer supported
bertsky 3f13747
CI: use Python images from CircleCI instead of DH
bertsky 6ead599
require Py37+
bertsky 89570a7
require Py37+
bertsky e1f6ed8
require Py37+
bertsky fed4128
require Py37+
bertsky af08d1e
require Py37+
bertsky 21c46c1
require Py37+
bertsky fe3303e
fix CI:
bertsky df7bfee
--help: clearer description of --page-id
kba 378400e
.circleci/config.yml: fix syntax
kba dbae7c4
.circleci/config.yml: fix syntax
kba 53f94b7
Merge branch 'dev-processing-broker-add-bashlib-processing-worker' of…
kba 25cc6fc
.circleci/config.yml: fix syntax
kba 176cf73
.circleci/config.yml: fix syntax
kba eeaafc4
Merge pull request #1024 from OCR-D/dev-processing-broker-add-bashlib…
MehmedGIT 2fa674f
Make receiving job info for procesor work again
joschrew 2fc3856
provide flexible queue checks
MehmedGIT 7835154
remove unnecessary checks
MehmedGIT 123366b
bruh, I need some rest for today
MehmedGIT 6fac7b8
check defaults, pass shallow copy
MehmedGIT bc9a29a
Update README.md
kba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """ | ||
| OCR-D CLI: start the processing server | ||
|
|
||
| .. click:: ocrd.cli.processing_server:processing_server_cli | ||
| :prog: ocrd processing-server | ||
| :nested: full | ||
| """ | ||
| import click | ||
| import logging | ||
| from ocrd_utils import initLogging | ||
| from ocrd_network import ( | ||
| ProcessingServer, | ||
| ProcessingServerParamType | ||
| ) | ||
|
|
||
|
|
||
| @click.command('processing-server') | ||
| @click.argument('path_to_config', required=True, type=click.STRING) | ||
| @click.option('-a', '--address', | ||
| default="localhost:8080", | ||
| help='The URL of the Processing server, format: host:port', | ||
| type=ProcessingServerParamType(), | ||
| required=True) | ||
| def processing_server_cli(path_to_config, address: str): | ||
| """ | ||
| Start and manage processing workers with the processing server | ||
|
|
||
| PATH_TO_CONFIG is a yaml file to configure the server and the workers. See | ||
| https://github.com/OCR-D/spec/pull/222/files#diff-a71bf71cbc7d9ce94fded977f7544aba4df9e7bdb8fc0cf1014e14eb67a9b273 | ||
| for further information (TODO: update path when spec is available/merged) | ||
|
|
||
| """ | ||
| initLogging() | ||
| # TODO: Remove before the release | ||
| logging.getLogger('paramiko.transport').setLevel(logging.INFO) | ||
| logging.getLogger('ocrd.network').setLevel(logging.DEBUG) | ||
kba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Note, the address is already validated with the type field | ||
| host, port = address.split(':') | ||
| processing_server = ProcessingServer(path_to_config, host, port) | ||
| processing_server.start() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """ | ||
| OCR-D CLI: start the processing worker | ||
|
|
||
| .. click:: ocrd.cli.processing_worker:processing_worker_cli | ||
| :prog: ocrd processing-worker | ||
| :nested: full | ||
| """ | ||
| import click | ||
| import logging | ||
| from ocrd_utils import ( | ||
| initLogging, | ||
| get_ocrd_tool_json | ||
| ) | ||
| from ocrd_network import ( | ||
| DatabaseParamType, | ||
| ProcessingWorker, | ||
| QueueServerParamType, | ||
| ) | ||
|
|
||
|
|
||
| @click.command('processing-worker') | ||
| @click.argument('processor_name', required=True, type=click.STRING) | ||
| @click.option('-q', '--queue', | ||
| default="amqp://admin:admin@localhost:5672/", | ||
| help='The URL of the Queue Server, format: amqp://username:password@host:port/vhost', | ||
| type=QueueServerParamType()) | ||
MehmedGIT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @click.option('-d', '--database', | ||
| default="mongodb://localhost:27018", | ||
| help='The URL of the MongoDB, format: mongodb://host:port', | ||
| type=DatabaseParamType()) | ||
MehmedGIT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def processing_worker_cli(processor_name: str, queue: str, database: str): | ||
| """ | ||
| Start a processing worker (a specific ocr-d processor) | ||
| """ | ||
| initLogging() | ||
| # TODO: Remove before the release | ||
| logging.getLogger('ocrd.network').setLevel(logging.DEBUG) | ||
kba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Get the ocrd_tool dictionary | ||
| # ocrd_tool = parse_json_string_with_comments( | ||
| # run([processor_name, '--dump-json'], stdout=PIPE, check=True, universal_newlines=True).stdout | ||
| # ) | ||
|
|
||
| ocrd_tool = get_ocrd_tool_json(processor_name) | ||
| if not ocrd_tool: | ||
| raise Exception(f"The ocrd_tool is empty or missing") | ||
|
|
||
| try: | ||
| processing_worker = ProcessingWorker( | ||
| rabbitmq_addr=queue, | ||
| mongodb_addr=database, | ||
| processor_name=ocrd_tool['executable'], | ||
| ocrd_tool=ocrd_tool, | ||
| processor_class=None, # For readability purposes assigned here | ||
| ) | ||
| # The RMQConsumer is initialized and a connection to the RabbitMQ is performed | ||
| processing_worker.connect_consumer() | ||
| # Start consuming from the queue with name `processor_name` | ||
| processing_worker.start_consuming() | ||
| except Exception as e: | ||
| raise Exception("Processing worker has failed with error") from e | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.