Comments (5)
here's some updated snippets to help you. Good luck! I'm just trying this repo out right now but it looks promising in terms of what I want to do.
def __init__(self, parser):
self.args = parser.parse_args()
self.loud = self.args.loud
self.log = self.configure_and_get_logger()
self.cli = docker.from_env()
self.api = docker.APIClient()
def build_task(self, directory_name):
self.log.info(f"Handling {directory_name}")
try:
self.copy_libraries(directory_name)
self.log.info("Building image. (run script with -l to see docker logs)")
build_logs = self.api.build(path=f'./docker/{directory_name}', tag=directory_name, rm=True)
while True:
try:
output = self.parse_output(next(build_logs))
if self.loud:
self.log.info(output)
except StopIteration:
self.log.info("Image built.")
break
finally:
self.remove_libraries(directory_name)
def parse_output(self, raw) -> str:
output = json.loads(raw)
try:
return output['stream'].strip('\n')
except KeyError:
return raw
from airflow_project.
The interface for docker-py has changed.
self.cli.images.build only returns an Image now
Update build_task to ignore the output of self.cli.images.build and this will let you build using this script
This means you won't get the build output anymore
If you want the build output looks like you need to get the APIClient from docker-py and call the low level build there. The low level build returns a stream of output but no Image object. The image object isn't used anyways..
from airflow_project.
from airflow_project.
You can be done using the low-level APIs given in docker-py as follows:
`
def build_task(self, directory_name):
self.log.info(f'Handling {directory_name}')
try:
self.copy_libraries(directory_name)
self.log.info('Building image. (run script with -l to see docker logs)')
docker_client = docker.Client(base_url='unix://var/run/docker.sock', timeout=10)
build_logs = docker_client.build(path=f'./docker/{directory_name}', tag=directory_name, rm=True)
for output in build_logs:
json_output = json.loads(output)
if self.loud and 'stream' in json_output:
self.log.info(json_output['stream'].strip('\n'))
self.log.info('Docker image built.')
# build_logs = self.api.build(path=f'./docker/{directory_name}', tag=directory_name, rm=True)
# while True:
# try:
# output = self.parse_output(next(build_logs))
# if self.loud:
# self.log.info(output)
# except StopIteration:
# self.log.info('Image built.')
# break
finally:
self.remove_libraries(directory_name)
`
from airflow_project.
Is this still an issue? Could any of you make a tiny pull request fixing this? :)
from airflow_project.
Related Issues (7)
- Auto Prune Containers HOT 1
- build_images returning SyntaxError even with python 3.6 HOT 1
- Enable mounting directories from host to task container on runtime HOT 1
- Why does the notebook image need to have a custom kernel and virtualenv? HOT 1
- puckel-airflow-with-docker-inside Removed HOT 1
- Set 'code.ipynb' on volumes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airflow_project.